Breaking News
Home / iOS / iOS Snippets / How to create vertical menu in Cocos2D?

How to create vertical menu in Cocos2D?

Snippet

In order to create a Menu in Cocos2D, simply create MenuItems and then add create the Menu with those items and finally align the items vertical for a vertical menu

  1. CCMenu *endMenu = nil;  
  2. [CCMenuItemFont setFontSize:25];
  3. [CCMenuItemFont setFontName:@"Marker Felt"];
  4.                
  5. CCMenuItem *restart = [CCMenuItemFont itemFromString:@"Restart"   target:self selector:@selector(restartGame:)];
  6.                
  7. CCMenuItem *more = [CCMenuItemFont itemFromString:@"Random Apps" target:self selector:@selector(moreGames:)];
  8.                
  9. CCMenuItem *submit = [CCMenuItemFont itemFromString:@"Submit Score" target:self
  10. selector:@selector(submitScore:)];
  11.                
  12. CCMenuItem *high = [CCMenuItemFont itemFromString:@"Top Ten" target:self
  13. selector:@selector(highScores:)];
  14.                
  15. endMenu = [[CCMenu menuWithItems:submit, [MenuLayer getSpacerItem], restart, [MenuLayer getSpacerItem], high, [MenuLayer getSpacerItem], more, nil] retain];
  16.                
  17. [endMenu alignItemsVertically];

<!>

[pb_builder]

Check Also

EKCalendar – That account does not allow calendars to be added or removed

Usecase When I am trying to create a new Calendar programmatically using the EventKit API …

Advertisment ad adsense adlogger