在级别选择屏幕中有菜单项并根据所选项目级别启动...这里是代码..其中 selectedLevel 是 menuItem 的索引。
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];