Cocos2d Mac OSX ccTouchesBegan + ccMouseDown

So you’re all set to port your fancy new Cocos2D game to the Mac App Store, but ccTouchesBegan is no longer defined!

No worries, you effectively have to replace all touch methods with mouse equivalents:

- ccTouchesBegan is now ccMouseDown
- self.isTouchEnabled is now self.isMouseEnabled
- check mouse click position using convertEventToGL

If ccMouseDown is not getting called, be sure self.isMouseEnabled is being set to YES.

Sample ccMouseDown:

-(BOOL)ccMouseDown:(NSEvent *)event {
CCLOG(@”Mouse clicked”);

CGPoint clickLocation = [[CCDirector sharedDirector] convertEventToGL:event];
return YES;
}

Written by

No Comments Yet.

Leave a Reply

Message