好的所以我有一个40级别的应用程序,我有一个滚动视图,按钮每个级别有不同的标签(级别1的标签为1,级别17的标签为17,等等......)< / p>
这些级别中的每一个都有一个SKScene类(level1.h / level1.m,level35.h / level35.m,等等),我将其中的每一个都导入到我的ViewController.m中,如下所示:
#import "level1.h"
#import "level2.h"
#import "level3.h"
#import "level4.h"
#import "level5.h"
#import "level6.h"
#import "level7.h"
#import "level8.h"
#import "level9.h"
#import "level10.h"
#import "level11.h"
#import "level12.h"
#import "level13.h"
你明白了
然后我有一个动作链接到所有40个按钮(有40个标签)直到相同的功能。然后我这样做了:
注意:您可能不需要阅读超过2个案例陈述以及最终和开头...我只是想彻底并提供所有这些。
-(IBAction)levelButtonPressed:(id)sender {
UIButton *button = (UIButton*)sender;
NSLog(@"button tag: %li",(long)button.tag);
// Configure the view.
skView = (SKView *)self.view;
SKScene *scene;
if (button.tag > [[NSUserDefaults standardUserDefaults] integerForKey:@"currentLevel"]) {
NSLog(@"level not available");
} else {
switch (button.tag) {
case 1:
// Create and configure the scene.
scene = [level1 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 2:
// Create and configure the scene.
scene = [level2 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 3:
// Create and configure the scene.
scene = [level3 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 4:
// Create and configure the scene.
scene = [level4 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 5:
// Create and configure the scene.
scene = [level5 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 6:
// Create and configure the scene.
scene = [level6 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 7:
// Create and configure the scene.
scene = [level7 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 8:
// Create and configure the scene.
scene = [level8 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 9:
// Create and configure the scene.
scene = [level9 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 10:
// Create and configure the scene.
scene = [level10 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 11:
// Create and configure the scene.
scene = [level11 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 12:
// Create and configure the scene.
scene = [level12 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 13:
// Create and configure the scene.
scene = [level13 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 14:
// Create and configure the scene.
scene = [level14 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 15:
// Create and configure the scene.
scene = [level15 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 16:
// Create and configure the scene.
scene = [level16 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 17:
// Create and configure the scene.
scene = [level17 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 18:
// Create and configure the scene.
scene = [level18 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 19:
// Create and configure the scene.
scene = [level19 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 20:
// Create and configure the scene.
scene = [level20 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 21:
// Create and configure the scene.
scene = [level21 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 22:
// Create and configure the scene.
scene = [level22 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 23:
// Create and configure the scene.
scene = [level23 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 24:
// Create and configure the scene.
scene = [level24 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 25:
// Create and configure the scene.
scene = [level25 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 26:
// Create and configure the scene.
scene = [level26 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 27:
// Create and configure the scene.
scene = [level27 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 28:
// Create and configure the scene.
scene = [level28 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 29:
// Create and configure the scene.
scene = [level29 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 30:
// Create and configure the scene.
scene = [level30 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 31:
// Create and configure the scene.
scene = [level31 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 32:
// Create and configure the scene.
scene = [level32 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 33:
// Create and configure the scene.
scene = [level33 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 34:
// Create and configure the scene.
scene = [level34 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 35:
// Create and configure the scene.
scene = [level35 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 36:
// Create and configure the scene.
scene = [level36 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 37:
// Create and configure the scene.
scene = [level37 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 38:
// Create and configure the scene.
scene = [level38 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 39:
// Create and configure the scene.
scene = [level39 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
case 40:
// Create and configure the scene.
scene = [level40 sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
break;
default:
break;
}
[skView presentScene:scene];
//levelSelect.hidden = YES;
scrollView.hidden = YES;
quitButton.hidden = NO;
}
}
所以我将代码提交给苹果,他们说它在iPad和iPhone 5s中崩溃了。我不知道该怎么做所以请帮助!我查看了所有内容,但它无法正常工作。
提前致谢,