Reputation: 1473
How do I get the coordinates of an touch event in objective-c using cocos2d?
- (void)touchBegan:(CCTouch *)touch withEvent:(CCTouchEvent *)event
{
CCLOG(@"Received a touchBegan");
}
Upvotes: 0
Views: 157
Reputation: 64477
CCTouch (currently missing in the class reference but will be added soon) has methods to get the touch locations:
// position in scene coordinates
CGPoint touchPos = [touch locationInWorld];
// touch position relative to anyNode's position
CGPoint touchPosNode = [touch locationInNode:anyNode];
Tip: In Xcode right-click a keyword such as CCTouch
and select Jump to Definition and it will bring you to the class interface which at least shows you the available properties/methods and for most of them you'll also find associated reference documentation as comments.
Upvotes: 1