前端之家收集整理的这篇文章主要介绍了
cocos2dx 动作篇 组合动作Spawn 和 Sequence,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Size visibleSize = Director::getInstance()->getVisibleSize();
@H_
404_0@
Vec2 origin = Director::getInstance()->getVisibleOrigin();
@H_
404_0@
Sprite * sp = Sprite::create("HelloWorld.png");
@H_
404_0@
sp->setPosition(Point(visibleSize.width/2,visibleSize.height/2));
@H_
404_0@
this->addChild(sp);
@H_
404_0@
@H_
404_0@
@H_
404_0@
//创建一个移动动作
@H_
404_0@
MoveBy * moveby = MoveBy::create(2.2f,Point(40,20));
@H_
404_0@
//创建一个弹跳的动作
@H_
404_0@
JumpBy * jumpby = JumpBy::create(3.0f,Point(50,1),100,1);
@H_
404_0@
//创建一个旋转动作
@H_
404_0@
RotateBy * rotateby = RotateBy::create(2.5f,220,10);
@H_
404_0@
///////////////////////////////////////创建组合动作将动作组合起来
//顺序执行
Action * action = Sequence::create(moveby,jumpby,rotateby,NULL);@H_404_0@
//一起执行
Action * action = Spawn::create(moveby,NULL); sp->runAction(action);