开发者

move sprite on path in cocos2d

I want to move a sprite on this path using cocos2d.

开发者_如何学编程

http://www.freeimagehosting.net/uploads/8436ca404e.jpg (stackoverflow does not allow new users to post image!)

Any help would me much appreciated!

Thanks


Here is a link for the actions using cocos2d. You could create an action with the positions and run the action when you want.

Actions

There are multiple actions for changing a sprites postion.

position

  CCMoveBy
  CCMoveTo
  CCJumpBy
  CCJumpTo
  CCBezierBy
  CCBezierTo
  CCPlace

You will find the links there.


You can use cardinalspline for moving sprite on set of points. it allows more then 3 points

Here is an example:

PointArray *pointarray=PointArray::create(5);
pointarray->addControlPoint(Vec2(50, 50));
pointarray->addControlPoint(Vec2(560, 50));
pointarray->addControlPoint(Vec2(255, 353));
pointarray->addControlPoint(Vec2(543, 534));
pointarray->addControlPoint(Vec2(354, 12));

sprite->runaction(CardinalSplineTo::create(3, pointarray, .5));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜