i'm starting to learn cocos2d, and i was wondering why actually we use convertToGL from CCDirector, [[CCDirector sharedDirector] convertToGL: touchLoc];
when we already have the [touch view]
from [touch locationInView: [touch view]];
?
Also, we first "addChild" a CCSprite, containing an image, and then we set its body, and the ccsprite becomes the data user of this body. Would'nt it better to "addChild" the body instead? or is it for any particular purpose?
Thanks
This is because the OpenGL View (EAGLView class) uses a different coordinate system than Cocoa Touch does.
For example, the 0,0 position for Cocoa Touch is on the upper left corner, whereas the 0,0 position for OpenGL is in the lower left corner. That's why you need to "convert to GL" all UIView coordinates.
The conversion also takes into account the current device orientation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With