我正在尝试为我的游戏制作动画,一只蚂蚁离开它的巢穴。它应该从右下角下降巢穴,面朝下,然后再次直视。
我创建了两个动作序列,一个用于移动,另一个用于旋转,并将它们放在一个 CCSpawn 中。如果我只执行移动动作,它可以正常工作,但是当动作一起执行时,最后精灵会回到原来的位置。
我不知道发生了什么。你们能帮忙吗?
CCLayer * gameLayer = CCLayer::create();
Ant* ant = Ant::create(); // Ant is a CCSprite
CCPoint nestp = ccp(45, 172);
ant->setPosition(nestp);
gameLayer->addChild(ant);
addChild(gameLayer);
// ant walking animation
CCAnimate * antWalk = CCAnimate::create(_antWalk);
ant->runAction(CCRepeatForever::create(antWalk));
CCPoint p1 = ccp(55, 165), p2 = ccp(75,160), p3 = ccp(90,110), p4 = ccp(105, 50);
CCSequence *moveOut = (CCSequence *)CCSequence::create(CCMoveTo::create(0.3, p1), CCMoveTo::create(0.3, p2), CCMoveTo::create(0.7, p3), CCMoveTo::create(0.7, p4), NULL);
CCSequence *rotateOut = (CCSequence *) CCSequence::create(CCRotateTo::create(0.5, 50), CCDelayTime::create(1), CCRotateTo::create(0.5, 0));
CCSpawn *leaveNest = (CCSpawn *)CCSpawn::create(moveOut, rotateOut, NULL);
ant->runAction(leaveNest);