iPhone, cocos2d coordinate system
I've created CocosNode, then inserted sprite in this node. I moved node and sprite 开发者_C百科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.
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]];
精彩评论