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);  

·¢±íÆÀÂÛ
Çë×Ô¾õ×ñÊØ»¥ÁªÍøÏà¹ØµÄÕþ²ß·¨¹æ£¬ÑϽû·¢²¼É«Çé¡¢±©Á¦¡¢·´¶¯µÄÑÔÂÛ¡£
Óû§Ãû: ÑéÖ¤Âë:µã»÷ÎÒ¸ü»»Í¼Æ¬
×îÐÂÆÀÂÛ ¸ü¶à>>

ÍƼöÈȵã

  • cocos2d-xѧϰ±Ê¼Ç(19)--label ¡¢label atlas
  • cocos2d-xѧϰ±Ê¼Ç(23)--µØͼµÄʹÓÃ3--CCTMXLayer
  • Cocos2d-xѧϰ£¨Ò»£©£ºHelloWorld
  • cocos2dxÔÚxcodeÏ¿ª·¢£¬±àÒëµ½androidÉÏ£¨2£©
  • cocos2d ÉèÖÃÆÁĻĬÈÏ·½Ïò
  • Cocos2d-x 2.0 Ö® Actions ¡°Èý°å¸«¡± Ö®Ò»
  • cocos2d-xѧϰ±Ê¼Ç(22)--µØͼµÄʹÓÃ2(TMX) --Z-Order¡¢AnchorPoi
  • cocos2d-xѧϰ±Ê¼Ç(18)--ÓÎÏ·´ò°ü£¨windowsƽ̨£©
  • cocos2d-xѧϰ±Ê¼Ç(16)--spritesheet(¾«Áé±íµ¥)

ÐÂÎŹØ×¢ÅÅÐаñ

ÈÈÃÅÍƼö ×îÐÂÍƼö
ÍøÕ¾Ê×Ò³ - ÓÑÇéÁ´½Ó - ÍøÕ¾µØͼ - TAG±êÇ© - RSS¶©ÔÄ - ÄÚÈÝËÑË÷
Copyright © 2008-2015 ¼ÆËã»ú¼¼Êõѧϰ½»Á÷Íø. °æȨËùÓÐ

Ô¥ICP±¸11007008ºÅ-1