-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event{CGPoint beginTouchPoint= [touch locationInView: [touch view]];beginTouchPoint = [[CCDirector sharedDirector] convertToGL:beginTouchPoint];beginTouchPoint = [self convertToNodeSpace:beginTouchPoint];return true;}
A blog with tutorials and solutions to the problems an every day programmer will hit who's new to cocos2d Follow on twitter http://twitter.com/#!/Ant_Run
Friday, 22 July 2011
Getting the position of a touch on screen as cocos2d ccp
Ok, this one took a bit of working out. But if you want to get the cpp point of a player's touch on a layer, you need to use the following code, after having enabled touch on the screen etc (see earlier blog post). This converts a CGPoint into coordinates that cocos2d can understand.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment