Anish
Anish

Reputation: 2917

Getting Position of a sprite in cocos2d

I am trying to get a each position of a sprite(curve),not only the center point,from starting point to end point.My sprite will rotate by 30deg when i tap on the screen.so i can't use sprite.position.x-sprite.contentSize.width/2 or some thing like that.Is there any way to get the position of a sprite or is there any other way to do this.

My need is i have different curve path.when i join those curve path,the new sprite should move along the curve path.

Upvotes: 0

Views: 1169

Answers (2)

HiTECNOLOGYs
HiTECNOLOGYs

Reputation: 327

If I correctly understood you, you want to get sprite coord(not center, bottom left corner) rotated by 30 degrees? For x axis use formula: newX = X + cos(30) * pathLong. For y use the same but replace cos by sin and x by y of course :).

Upvotes: 0

Andrew
Andrew

Reputation: 24846

I think you are looking for convertToWorldSpace function of CCNode.

Upvotes: 2

Related Questions