cocos2d-x中的动作

来源:互联网 发布:资海网络集团怎么样 编辑:程序博客网 时间:2024/06/11 10:36


创建Scene场景,添加Sprite精灵对象到屏幕上只是其中一部分。

游戏之所以称为游戏就是我们需要让精灵运动起来!Action动作游戏中的一部分。_Actions_动作类可以让Node节点对象按时间进行运动。

希望将一个Sprite精灵从一个坐标点移动到另一个坐标并在结束时调用回调函数?没有问题!

你可以创建一个Actions动作序列Sequence并且按顺序播放。你可以通过改变Node节点属,坐标,角度,缩放。比如说这些动作:MoveByRotateScale。所有的游戏都使用动作类Actions

_Actions_很容易创建使用:

auto mySprite = Sprite::create("Blue_Front1.png"); // Move a sprite 50 pixels to the right, and 10 pixels to the top over 2 seconds.auto moveBy = MoveBy::create(2, Vec2(50,10));mySprite->runAction(moveBy); // Move a sprite to a specific location over 2 seconds.auto moveTo = MoveTo::create(2, Vec2(50,10));mySprite->runAction(moveTo);


0 0
原创粉丝点击