开发者

move sprite on path in cocos2d

开发者 https://www.devze.com 2022-12-26 20:48 出处:网络
I want to move a sprite on this path using cocos2d. 开发者_如何学编程http://www.freeimagehosting.net/uploads/8436ca404e.jpg

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

精彩评论

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