cocos2dx¶¯»Animation½éÉÜ(2)
À´Ô´£ºÎ´Öª ÔðÈα༣ºÔðÈα༠·¢±íʱ¼ä:2013-11-17 14:34¡¡µã»÷:´Î
p>addChild(spritebatch);
p>
p>
p>createWithSpriteFrameName ·½·¨½«»á´Ógrossini.plistÖÐÕÒµ½¶ÔÓ¦µÄ×ø±êÒÔ¼°¾ØÐÎÇøÓò£¬Ö®ºóÔٲüôgrossini.pngµÄÎÆÀí³ÉÒ»¸ö¾«ÁéÖ¡¡£
p>
p>
p>ÏÖÔÚÎÒÃÇ´´½¨Ò»¸öCCArray¶ÔÏó²¢ÇÒÌì½£ËùÓеÄÖ¡¶¯»½øÈ¥¡£ÔÚÕâ¸ö¶¯»µÄÀý×ÓÖУ¬ÎÒÃÇ·¢ÏÖËùÓеÄ14Ö¡¶¼ÓÐÏàͬµÄ´óС£¬ËùÒÔÎÒÃÇ¿ÉÒÔÓÃÒ»¸öǶÌ×µÄÑ»·±éÀúËüÃÇ£¬²¢ÇÒµ±Íê³ÉÌí¼Ó14Ö¡Ö®ºó½áÊøµôÑ»·¡£
p>[cpp]
p>CCArray* animFrames = CCArray::createWithCapacity(15);
p>char str[100] = {0};
p>
p>for(int i = 1; i < 15; i++)
p>{
p> sprintf(str, "grossini_dance_%02d.png", i);
p> CCSpriteFrame* frame = cache->spriteFrameByName( str );
p> animFrames->addObject(frame);
p>}
p>
p>×îºó£¬ÎÒÃÇÐèÒª´´½¨Ò»¸öCCAnimate¶¯×÷ʵÀýÀ´ÔËÐÐCCSprite¡£ÏÂÃæÎÒÃÇ¿ÉÒÔÔÚCCRepeatForever¶¯×÷Öаü¹üCCAnimate¶¯×÷À´ÈÃËüÒ»Ö±Ö´ÐÐÏÂÈ¥£¬ÏñÕâÑù£º
p>[cpp]
p>CCAnimation* animation = CCAnimation::createWithSpriteFrames(animFrames, 0.3f);
p>m_pSprite1->runAction( CCRepeatForever::create( CCAnimate::create(animation) ) );
p>
p>ËÄ¡¢Îļþ¶¯»
p>CCAnimateCacheÄܹ»¼ÓÔØÒ»¸öÃèÊöÒ»Åú½ÚµãµÄxml/plistÎļþ£¬°üÀ¨Ö¡ÃûºÍËûÃǵľØÐÎÇøÓò¡£Õâ¸ö½è¿Ú·Ç³£ÈÝÒ×ʹÓá£
p>[cpp]
p>CCAnimationCache *cache = CCAnimationCache::sharedAnimationCache(); // »º´æÔÚcocos2dxÖÐÒ»Ö±Êǵ¥Àýģʽ
p>cache->addAnimationsWithFile("animations/animations-2.plist");
p>CCAnimation animation = cache->animationByName("dance_1");
p>CCAnimate animate = CCAnimate::create(animation);
p>sprite->runAction(animate);
Ïà¹ØÐÂÎÅ>>
- Cocos2dx3.2±àд³£ÓÃUI×é¼þ£¨Ò»£©ÐÂÊÖÖ¸µ¼¿òGuideLayer
- cocos2dxÖ®²ÊÉ«±à¼ÊäÈë¿òµÄÉè¼Æ
- Cocos2dx3.2±àд³£ÓÃUI×é¼þ£¨Èý£©ÊÕ¼¯Æ÷Ч¹ûCollector
- cocos2dx 3.2 ²Ã¼ô½Úµã ClippingNode
- cocos2dxÖ®³é½±½çÃæÓë»ñ½±¸ÅÂʵÄÉè¼Æ(Ò»)
- cocos2dx±³¾°Í¸Ã÷´¦Àí
- cocos2dx 3.xÅжÏnodeµã»÷ÇøÓòÊÇ·ñ͸Ã÷
- cocos2dxµÄrunAction: Öظ´Ö´ÐÐ,¶à¸ö¶¯×÷Á¬½ÓÖ´ÐÐ,¶à¸ö¶¯×÷ͬʱ
- ¹ØÓÚcocos2dx luaÖеÄcloneº¯ÊýµÄÔ´Âë½â¶Á
- cocos2dx V3.2 mac os Xcode6.1 »·¾³ÅäÖÃ
×îÐÂÍƼö¸ü¶à>>>
ÈÈÃÅÐÂÎŽøÈëÒƶ¯¿ª·¢ÆµµÀ>>
- ·¢±íÆÀÂÛ
-
- ×îÐÂÆÀÂÛ ¸ü¶à>>
Äú¿ÉÄܸÐÐËȤµÄÎÄÕÂ
- Cocos2d-xѧϰ£¨Ò»£©£ºHelloWorld
- ÓÃcocos2d-html5×öµÄÏû³ýÀàÓÎÏ·¡¶Ó¢ÐÛ°®Ïû³ý¡·(1)¡ª¡ªÏµÍ³Ö÷²Ëµ¥
- Cocos2d-x µÄ¡°HelloLua¡± ÉîÈë·ÖÎö
- cocos2dx Sprite setBlendFunc ʹÓÃÑÕÉ«»ìºÏ£º¼ÓË㣬¼õËã
- cocos2d-x CCRotateTo ¶Ô³õʼ½Ç£¬Ðýת½ÇµÄ´¦Àí
- cocos2d-x ActionManager¿ØÖƾ«ÁéµÄÔÝÍ£Ô˶¯
- cocos2d-x 3.0rc ½ÏÓÚ2.2v Öî¶à±ä»¯ÖеÄһЩСµã
- cocos2d-xÔÚwin32ºÍiOS¡¢androidÏ»ñÈ¡µ±Ç°ÏµÍ³Ê±¼äµÄ·½·¨
- ibatis ¹ØÁª×Ô¼º£¬ÔõôӳÉä xml £¿
- ¡¶BREW½ø½×Ó뾫ͨ¡ª¡ª3GÒƶ¯ÔöÖµÒµÎñµÄÔËÓª¡¢¶¨ÖÆÓ뿪·¢¡·Á¬ÔØÖ®