1
我決定堅持使用cocos2d作爲遊戲開發...對於菜單,有一種方法可以使其更具可定製性,就像也許而不是文本也許是一個圖像,然後有一種方法來安排他們不同的方式而不僅僅是在屏幕的中心自定義Cocos2D菜單
我決定堅持使用cocos2d作爲遊戲開發...對於菜單,有一種方法可以使其更具可定製性,就像也許而不是文本也許是一個圖像,然後有一種方法來安排他們不同的方式而不僅僅是在屏幕的中心自定義Cocos2D菜單
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:)];
你CON做
MenuItem *start = [MenuItemImage itemFromNormalImage:@"NameOfYourNormalImage.png" selectedImage:@"NameOfYourSelectedImage.png" target:self selector:@selector(start:)];
要定位你的菜單,你應該定義一個CGPoint並將菜單位置設置到這一點。
[menu setPosition:ccp(PositionOnX, PositionOnY)];
我希望這是你在找什麼。
乾杯,
VFN
謝謝!我剛剛做了菜單式的照片 – techy