开发者

iPhone, cocos2d coordinate system

开发者 https://www.devze.com 2022-12-20 20:23 出处:网络
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 scree

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]];
0

精彩评论

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

关注公众号