IPhone cocos2d coordinate system

I created CocosNode, then inserted a sprite into this node. I moved node and sprite separately. As a result, node has some coordinate, sprite has a different coordinate. I see a sprite on the screen, but the coordinates of the sprite are outside the borders of the screen.

Could you explain how to convert sprite coordinates to screen coordinates?

Thank.

+3
source share
1 answer

Cocos provides methods for this. To convert from your node position to world space (the coordinate system of the coconut, y increases at the top of the screen), you must:

[aSprite convertToWorldSpace:aSprite.position];

iPhone (y ):

[[CCDirector sharedDirector] convertToGL:[aSprite convertToWorldSpace:aSprite.position]];
+6

Source: https://habr.com/ru/post/1733488/


All Articles