Hello,
I have absolutely no idea what is going wrong with my code but I cannot call a method from a click on a button. If anybody have any leads or tips to fix this issue it'll be cool.
(Sorry I don't know the tag to format the src code below)
Layer *layer = [[Layer alloc] init];
layer.isTouchEnabled = YES;
_music_btn = [MenuItemImage itemFromNormalImage:@"btn_music.png" selectedImage:@"btn_music.png" target:self selector:@selector(clickHandler:)];
_sound_btn = [MenuItemImage itemFromNormalImage:@"btn_sound.png" selectedImage:@"btn_sound.png" target:self selector:@selector(clickHandler:)];
_quality_btn = [MenuItemImage itemFromNormalImage:@"btn_quality.png" selectedImage:@"btn_quality.png" target:self selector:@selector(clickHandler:)];
Menu *menuBottomRight = [Menu menuWithItems: _music_btn,_sound_btn,_quality_btn,nil];
menuBottomRight.position = ccp( size.width -28/2-5, (28*3+10*3)/2 );
[menuBottomRight alignItemsVerticallyWithPadding:10.0];
[layer addChild:menuBottomRight];
/* ......
I add other Menus to the layer
*/
[self.manager.container addChild:layer]; //self.manager.container is layer attached to a scene
/* ......*/
-(void) clickHandler:(id)e {
NSLog(@"["__FILE__":%i] clickHandler",__FILE__,__LINE__);
}
Below you can see an error message appearing when I click on the last MenuItemImage of the last Menu added to the layer:
#0 0x918f8688 in objc_msgSend ()
#1 0x3024a10d in __invoking___ ()
#2 0x30249ff8 in -[NSInvocation invoke] ()
#3 0x0001de17 in -[MenuItem activate] (self=0xe24ec0, _cmd=0x9195934c) at /Users/wizermil/Desktop/Work/uphill_rush_2/code/tmp/Test/cocos2d/MenuItem.m:99
#4 0x0001b0f4 in -[Menu ccTouchEnded:withEvent:] (self=0xe60a60, _cmd=0x368c7, touch=0x6805b30, event=0xe13bf0) at /Users/wizermil/Desktop/Work/uphill_rush_2/code/tmp/Test/cocos2d/Menu.m:198
#5 0x0002d9e9 in -[TargetedTouchHandler updateKnownTouches:withEvent:selector:unclaim:] (self=0xe8a790, _cmd=0x3a33c, touches=0x689f7b0, event=0xe13bf0, selector=0x368c7, doUnclaim=1 '01') at /Users/wizermil/Desktop/Work/uphill_rush_2/code/tmp/Test/cocos2d/TouchHandler.m:170
#6 0x0002d82f in -[TargetedTouchHandler ccTouchesEnded:withEvent:] (self=0xe8a790, _cmd=0x36846, touches=0x689f7b0, event=0xe13bf0) at /Users/wizermil/Desktop/Work/uphill_rush_2/code/tmp/Test/cocos2d/TouchHandler.m:153
#7 0x0002ca4e in -[TouchDispatcher touchesEnded:withEvent:] (self=0xe21230, _cmd=0x3199fa0c, touches=0x689fb80, event=0xe13bf0) at /Users/wizermil/Desktop/Work/uphill_rush_2/code/tmp/Test/cocos2d/TouchDispatcher.m:187
#8 0x000237f4 in -[EAGLView touchesEnded:withEvent:] (self=0xe1b320, _cmd=0x3199fa0c, touches=0x689fb80, event=0xe13bf0) at /Users/wizermil/Desktop/Work/uphill_rush_2/code/tmp/Test/cocos2d/Support/EAGLView.m:305
#9 0x30910fdf in -[UIWindow _sendTouchesForEvent:] ()
#10 0x308faecb in -[UIApplication sendEvent:] ()
#11 0x309013e1 in _UIApplicationHandleEvent ()
#12 0x32046375 in PurpleEventCallback ()
#13 0x30245560 in CFRunLoopRunSpecific ()
#14 0x30244628 in CFRunLoopRunInMode ()
#15 0x32044c31 in GSEventRunModal ()
#16 0x32044cf6 in GSEventRun ()
#17 0x309021ee in UIApplicationMain ()
#18 0x000028d4 in main (argc=1, argv=0xbfffef10) at /Users/wizermil/Desktop/Work/uphill_rush_2/code/tmp/Test/main.m:13
Thanks in advance for your help