views:

878

answers:

1

Hi, I've created CocosNode, then inserted sprite in this node. I moved node and sprite separately. As result node has some coordinate, sprite has another coordinate. I see sprite on the screen, but sprite's coordinates are out of the screen borders.

So could you please explain how can I convert sprite coordinates to screen coordinates?

Thanks.

A: 

Cocos provides methods for this. To convert from your node's position to world space (cocos coord system, y increases toward the top of the screen) you would do:

[aSprite convertToWorldSpace:aSprite.position];

To convert from this coord system to iPhone view coord system (y increases toward the bottom of the screen) do:

[[CCDirector sharedDirector] convertToGL:[aSprite convertToWorldSpace:aSprite.position]];
CJ Hanson