gpt4 book ai didi

cocos2d-x 动画循环播放

转载 作者:行者123 更新时间:2023-12-03 08:13:33 24 4
gpt4 key购买 nike

一个动画从a点移动到b点,在移动过程中,动画需要循环播放。例如,一颗子弹移动到一个点,这个子弹是一个动画,应该循环播放。

CCSequence::create(
CCSpawn::createWithTwoActions(
CCTargetedAction::create(sprite, CCMoveTo::create(3.0f, point_a)),
CCTargetedAction::create(sprite, CCRepeatForever::create(CCAnimate::create(animation)))
),0);

但是CCRepeatForever不能是action sequence的成员。那怎么办呢?我用sequence是因为还有其他action要排队(上面略)

最佳答案

您不需要为此使用 ccspawn.. 也不需要 ccsequence 只对对象分别运行这两个操作。

CCSprite *newSprite=CCSprite::create("imageName");

CCAnimation *animation=CCAnimation::create();

//..some code to add frames to this animation object..

//to repeat for indefinite time you could setLoops to -1 or use CCRepeatForever class //like this..
//1:

animation->setLoops(-1);
newSprite->runAction(CCAnimate:create(animation));

//or..

//2:

newSprite->runAction(CCRepeatForever:create(CCAnimate:create(animation)));

//now to translate this sprite simultaneously use this.

newSprite->runAction(CCMoveTo::create(3.0,point_a));

关于cocos2d-x 动画循环播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20115184/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com