我决定继续使用cocos2d作为游戏开发人员。对于菜单,有一种方法可以使其更具可定制性,比如也许可以代替文本或者图像,那么是否有一种方法可以将它们排列成不同的方式,而不是仅仅在屏幕的中心
发布于 2010-01-13 23:05:38
Check the tutorial that I have done for cocos2d menus。
显示图像而不是文本非常简单,您应该在创建菜单项时选择这一点。看一看MenuItemImage类。
正如您在建议的教程中所看到的,这段代码创建了一个菜单
// Creating menu items
MenuItem *start = [MenuItemFont itemFromString:@"Start" target:self selector:@selector(start:)];
MenuItem *settings = [MenuItemFont itemFromString:@"Settings" target:self selector:@selector(settings:)];
MenuItem *credits = [MenuItemFont itemFromString:@"Credits" target:self selector:@selector(credits:)];
MenuItem *help = [MenuItemFont itemFromString:@"Help" target:self selector:@selector(help:)];
// Creating menu and adding items
Menu *menu = [Menu menuWithItems:start, settings, credits, help, nil];
// Set menu alignment to vertical
[menu alignItemsVertically];
在您的例子中,不使用:
MenuItem *start = [MenuItemFont itemFromString:@"Start" target:self selector:@selector(start:)];
你可以做到
MenuItem *start = [MenuItemImage itemFromNormalImage:@"NameOfYourNormalImage.png" selectedImage:@"NameOfYourSelectedImage.png" target:self selector:@selector(start:)];
要定位菜单,您应该定义一个CGPoint并将菜单位置设置为该点。
[menu setPosition:ccp(PositionOnX, PositionOnY)];
我希望这就是你要找的。
干杯,
VFN
https://stackoverflow.com/questions/2047008
复制相似问题