植物大战僵尸的植物摇摆效果
1 //帧动画 2 Animation *animation = Animation::create(); 3 4 Sprite *sprite = Sprite::create("1.png"); 5 sprite->setPosition(Vec2(400, 400)); 6 this->addChild(sprite); 7 8 for(int i=2; i<9; i++) 9 { 10 __String *string = __String::createWithFormat("%d.png",i); 11 SpriteFrame *sf = SpriteFrame::create(string->getCString(), Rect(0, 0, 120, 65)); 12 animation->addSpriteFrame(sf); 13 } 14 15 animation->setDelayPerUnit(0.2); 16 animation->setLoops(-1); 17 18 Animate *animate = Animate::create(animation); 19 sprite->runAction(animate);