iphone - Cocos2d CCMenuItem target gives SIGABRT -
i'm trying create menu system calls method depending on pressed. problem when add target , selector ccmenuitems.it crashes sgabrt error. know problem target, should be? here .h , .m code
#import "cocos2d.h" // splashmenulayer @interface splashmenulayer : cclayer { bool menubuttonsshowing; cclabelttf * splashlabel; ccmenuitemfont * puzzlemenuitem; ccmenuitemfont * racemenuitem; ccmenuitemfont * leaderboardmenuitem; ccmenu * mainmenu; } // returns ccscene contains helloworldlayer child +(ccscene *) scene; -(bool) cctouchbegan:(uitouch *)touch withevent:(uievent *)event; -(void) cctouchended:(nsset *)touches withevent:(uievent *)event; -(void) deletelabel :(id)sender; -(void) puzzlemode:(id)sender; -(void) racemode:(id)sender; -(void) leaderboard:(id)sender; @property bool menubuttonsshowing; @property (nonatomic, retain) cclabelttf* splashlabel; @property (nonatomic, retain) ccmenuitem* puzzlemenuitem; @property (nonatomic, retain) ccmenuitem* racemenuitem; @property (nonatomic, retain) ccmenuitem* leaderboardmenuitem; @property (nonatomic, retain) ccmenu* mainmenu; @end
and finally
-(void) cctouchended:(nsset *)touches withevent:(uievent *)event{ if (menubuttonsshowing == no) { id action = [ccsequence actions:[ccfadeout actionwithduration:0.5],[cccallfunc actionwithtarget:self selector:@selector(deletelabel:)], nil]; [splashlabel runaction:action]; //create menu items , target/selector puzzlemenuitem = [ccmenuitemfont itemfromstring:@"puzzle mode" target:self selector:@selector(puzzlemode:)]; racemenuitem = [ccmenuitemfont itemfromstring:@"race mode" target:self selector:@selector(racemode:)]; leaderboardmenuitem = [ccmenuitemfont itemfromstring:@"leaderboard" target:self selector:@selector(leaderboard:)]; //add menu items menu mainmenu = [ccmenu menuwithitems:puzzlemenuitem, racemenuitem, leaderboardmenuitem, nil]; [mainmenu alignitemsvertically]; mainmenu.position = ccp(240, 100); [self addchild:mainmenu]; } } -(void) puzzlemode:(id)sender{ nslog(@"lol1"); } -(void) racemode:(id)sender{ nslog(@"lol2"); } -(void) leaderboard:(id)sender{ nslog(@"lol3");
}
correct line capital l
leaderboardmenuitem = [ccmenuitemfont itemfromstring:@"leaderboard" target:self selector:@selector(leaderboard:)];
to
leaderboardmenuitem = [ccmenuitemfont itemfromstring:@"leaderboard" target:self selector:@selector(leaderboard:)];
Comments
Post a Comment