I have been trying to detect specific trackpad touches but it seems to be disabled in cocos2d by this code
#pragma mark CCEventDispatcher - Touch events
- (void)touchesBeganWithEvent:(NSEvent *)event
{
if (dispatchEvents_ ) {
NSLog(@"Touch Events: Not supported yet");
}
}
- (void)touchesMovedWithEvent:(NSEvent *)event
{
if (dispatchEvents_ ) {
NSLog(@"Touch Events: Not supported yet");
}
}
- (void)touchesEndedWithEvent:(NSEvent *)event
{
if (dispatchEvents_ ) {
NSLog(@"Touch Events: Not supported yet");
}
}
- (void)touchesCancelledWithEvent:(NSEvent *)event
{
if (dispatchEvents_ ) {
NSLog(@"Touch Events: Not supported yet");
}
}
#pragma mark CCEventDispatcher - queue events
in my scene i did this in the init :
[[[CCDirectorMac sharedDirector] openGLView] setAcceptsTouchEvents:YES];
and tried this code:
- (void)touchesBeganWithEvent:(NSEvent *)ev {
NSLog(@"bla");
NSSet *touches = [ev touchesMatchingPhase:NSTouchPhaseBegan inView:[[CCDirectorMac sharedDirector] openGLView]];
for (NSTouch *touch in touches) {
/* Once you have a touch, getting the position is dead simple. */
NSPoint fraction = touch.normalizedPosition;
NSSize whole = touch.deviceSize;
NSSize wholeInches = {whole.width / 72.0, whole.height / 72.0};
NSPoint pos;
pos.x = wholeInches.width;
pos.y = wholeInches.height;
pos.x *= fraction.x;
pos.y *= fraction.y;
NSLog(@"%s: Finger is touching %g inches right and %g inches up "
@"from lower left corner of trackpad.", __func__, pos.x, pos.y);
}
}
but the message saying not supported yet still pops up.
