首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >cocos2d-x动画循环播放

cocos2d-x动画循环播放
EN

Stack Overflow用户
提问于 2013-11-21 07:47:37
回答 1查看 7K关注 0票数 3

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

代码语言:javascript
运行
复制
CCSequence::create(
  CCSpawn::createWithTwoActions(
    CCTargetedAction::create(sprite, CCMoveTo::create(3.0f, point_a)), 
    CCTargetedAction::create(sprite, CCRepeatForever::create(CCAnimate::create(animation)))
),0);

但CCRepeatForever不能成为动作序列的成员。那怎么做呢?我使用序列是因为还有其他动作在排队(上面省略了)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-11-29 06:43:52

你不需要用ccspawn来做这个..。也不是ccsequence只在对象上单独运行两个操作。

代码语言:javascript
运行
复制
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));
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20115184

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档