帧动画和旋转

来源:互联网 发布:mysql如何查看 编辑:程序博客网 时间:2024/05/22 00:43
CCSprite* pSprite = CCSprite::create("scene15_pig01_01.png");pSprite->setPosition(ccp(400,200));
this->addChild(pSprite, 0,3);

CCAnimation *animation = CCAnimation::create();
animation->addSpriteFrameWithFileName("1.png");
animation->addSpriteFrameWithFileName("2.png");
animation->addSpriteFrameWithFileName("3.png");
    animation->setDelayPerUnit(2.8f / 14.0f);// This animation contains 14 frames, will continuous 2.8 seconds.
animation->setRestoreOriginalFrame(true);// Return to the 1st frame after the 14th frame is played.
CCAnimate *action = CCAnimate::create(animation);
CCRepeatForever* mFly=CCRepeatForever::actionWithAction( CCAnimate::actionWithAnimation(animation));  
pSprite->runAction(mFly);


CCLOG("add MCCSprite");
CCSprite* sprite = MCCSprite::create("scene11_windmill_yy.png");
sprite->setPosition(ccp(700, 500));
    this->addChild(sprite, 0);
CCRotateBy* rotate = CCRotateBy::actionWithDuration(1, 360);
CCRepeatForever* repeatRotate = CCRepeatForever::actionWithAction(rotate);
sprite->runAction(repeatRotate);
原创粉丝点击