Reputation: 13
CCTouch* touch = (CCTouch*)( touches->anyObject() );
CCPoint location = touch->locationInView();
location = CCDirector::sharedDirector()->convertToGL(location);
Could anybody explain me what is that method for and why is neccesary to use!?
Thanks
Upvotes: 0
Views: 941
Reputation: 8729
UIKit coordinates have the Y coordinate starting in the top left. OpenGL has the Y coordinate start from the bottom left.
convertToGL()
simply converts a top left coordinate system into a bottom left coordinate system by subtracting the Y coordinate from the height of the screen.
Another note, cocos2d is completely open source, if you want to know what a function does, just have a look at the source code.
Upvotes: 2