ホームページ  >  記事  >  データベース  >  cocos2dx 动作篇 组合动作Spawn 和 Sequence

cocos2dx 动作篇 组合动作Spawn 和 Sequence

WBOY
WBOYオリジナル
2016-06-07 15:24:351468ブラウズ

Size visibleSize = Director::getInstance()-getVisibleSize(); Vec2 origin = Director::getInstance()-getVisibleOrigin(); Sprite * sp = Sprite::create(HelloWorld.png); sp-setPosition(Point(visibleSize.width/2,visibleSize.height/2)); this-addCh

Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
Sprite * sp = Sprite::create("HelloWorld.png");
sp->setPosition(Point(visibleSize.width/2,visibleSize.height/2));
this->addChild(sp);


//创建一个移动动作
MoveBy * moveby = MoveBy::create(2.2f, Point(40, 20));
//创建一个弹跳的动作
JumpBy * jumpby = JumpBy::create(3.0f, Point(50,1),100,1);
//创建一个旋转动作
RotateBy * rotateby = RotateBy::create(2.5f, 220, 10);

///////////////////////////////////////创建组合动作将动作组合起来

//顺序执行

Action * action = Sequence::create(moveby, jumpby, rotateby, NULL);

//一起执行

Action * action = Spawn::create(moveby, jumpby, rotateby, NULL);
sp->runAction(action);
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。