그림으로 된 소스 첨부.
<실제 구현된 소스>
void FirstGame::createBirds(float dt)
{
CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache();
cache->addSpriteFramesWithFile("bird_ani.plist");
CCSprite* bird = CCSprite::createWithSpriteFrameName("bird_ani_1.png");
bird->setPosition( ccp( s.width + bird->getContentSize().width/2, BIRD_Y) );
bird->setScale(0.5f);
this->addChild(bird, 10);
m_listBird->addObject(bird);
CCAnimation *animation = CCAnimation::create();
animation->setDelayPerUnit(0.15f);
animation->addSpriteFrame( cache->spriteFrameByName("bird_ani_1.png") );
animation->addSpriteFrame( cache->spriteFrameByName("bird_ani_2.png") );
animation->addSpriteFrame( cache->spriteFrameByName("bird_ani_3.png") );
animation->addSpriteFrame( cache->spriteFrameByName("bird_ani_4.png") );
animation->addSpriteFrame( cache->spriteFrameByName("bird_ani_5.png") );
CCAnimate* aniBird = CCAnimate::create(animation);
CCRepeatForever *pBirdAniRep = CCRepeatForever::create(aniBird);
bird->runAction(pBirdAniRep);
CCMoveTo* pMove = CCMoveTo::create(BOX_MOVE_SEC * 0.8f, ccp(0 - bird->getContentSize().width/2, BIRD_Y) );
CCCallFuncN* pAfter = CCCallFuncN::create(this, callfuncN_selector(FirstGame::removeBird));
bird->runAction( CCSequence::create(pMove, pAfter, NULL) );
}
'Cocos2D-x' 카테고리의 다른 글
Google Play Game Services SDK (0) | 2014.08.18 |
---|---|
CCSpriteBatchNode (0) | 2014.08.14 |
[cocos2d-x 3.0] ParallaxNode (0) | 2014.08.13 |
[Menu] Touch Action을 지정할 수 있는 메뉴 클래스 (0) | 2014.05.09 |
GraySprite Class (0) | 2014.04.24 |