0

9 つの異なるシナリオ用に 34 個の .png 画像ファイルがあります。ユーザーがこれらの 9 つのシナリオの 1 つを選択するたびに、それに応じて、次を使用してアニメーションを生成します。

 std::string name;
 MixingScreen::animation = CCAnimation::create();
 // load image file from local file system to CCSpriteFrame, then add into CCAnimation
 for (int i = 0; i < 34; i++)
 {
     std::stringstream st,ii;
     st << Constants::flav;
     if (i<10)
     {
         ii<<i;
        name="screen/screen02/fx/sugar/0" + st.str()+"/a_0000"+ii.str()+".png";
     }
     else
     {
         ii<<i;
        name="screen/screen02/fx/sugar/0" + st.str()+"/a_000"+ii.str()+".png";
     }
        //sprintf(szImageFileName, "Images/grossini_dance_%02d.png", i);
     MixingScreen::animation->addSpriteFrameWithFileName(name.c_str()); 
     }
     MixingScreen::animation->setDelayPerUnit(5.0f / 34.0f);

    action = CCAnimate::create(MixingScreen::animation);
    CCCallFunc *done = CCCallFunc::create(this, callfunc_selector(MixingScreen::doneMixing));
    CCSequence *readySequence = CCSequence::create(action,done,NULL);
    particles->runAction(readySequence);  

私が直面している問題は、このアニメーションが実行されると、タイムラグ (すべてが数秒間停止する) があり、その後アニメーションが開始されることです。解決策はありますか?

4

1 に答える 1

2

animation->addSpriteFrameWithFileName() を呼び出すたびに、新しい「CCSpriteFrame」が作成されます。

代わりに、最初にスプライト フレームを CCSpriteFrameCache に追加して使用する必要があります。

animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameWithName(""))

追伸: これらの関数名は少し異なるかもしれませんが、理解していただければ幸いです。

于 2013-07-20T08:48:59.893 に答える