cocos2d 帧动画1

    CCSize size=CCDirector::sharedDirector()->getWinSize(); 
    CCSprite* sprite=CCSprite::create("s_1.png");
    sprite->setPosition(ccp(size.width/2,size.height/2));
    this->addChild(sprite);

    CCAnimation* animation=CCAnimation::create();
    char str[50];
    for(int i=1;i<9;i++)
    {
        sprintf(str,"s_%d.png",i);
        animation->addSpriteFrameWithFileName(str);
    }
    animation->setDelayPerUnit(0.1);
    animation->setRestoreOriginalFrame(true);
    //sprite->runAction(CCAnimate::create(animation));//执行一边
    sprite->runAction(CCRepeatForever::create(CCAnimate::create(animation)));

 

posted @ 2014-04-02 11:52  yufenghou  阅读(178)  评论(0编辑  收藏  举报