在水平選擇屏幕上具有菜單項並取決於選定的項目級別開始...這裏是代碼..其中selectedLevel是menuItem的索引。問題與選擇水平表單水平選擇屏幕(Cocos2d + box2d)
if(selectedLevel==0)
{
activeScene = [level2_1Scene node];
[[CCDirector sharedDirector] pushScene:activeScene];
}
else if(selectedLevel==1)
{
activeScene = [level2_2Scene node];
[[CCDirector sharedDirector] pushScene:activeScene];
}
else if(selectedLevel==2)
{
activeScene = [level2_3Scene node];
[[CCDirector sharedDirector] pushScene:activeScene];
...等所有級別
如何與水平場景名稱像這樣簡單的格式做這工作不
activeScene = [[NSString stringWithFormat:@"level2_%d",selectedLevel+1] node];
[[CCDirector sharedDirector] pushScene:activeScene];