按下后退按钮时应用程序崩溃

时间:2015-04-27 09:55:38

标签: uiviewcontroller skscene skemitternode

问题:

每次按“< chat”按钮时,我的应用都会崩溃(只有当我将紫色SKEmitterNode添加到GameScene.m时才会发生这种情况。)

enter image description here

错误:

enter image description here

enter image description here

代码:

1)来自UIViewController目前的DrawDrawViewController(UIViewController):

DrawDrawViewController *drawDrawViewController = [[DrawDrawViewController alloc] init];
[self.navigationController pushViewController:drawDrawViewController animated:YES];

2)内部DrawDrawViewController(UIViewController)显示GameScene(SKScene)

@interface DrawDrawViewController()
@property (nonatomic) SKView *drawDrawView;
@property (nonatomic) GameScene *scene;
@end


- (void)viewDidLoad {
    [super viewDidLoad];

    // Configure the view.
    _drawDrawView = [[SKView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];

    [self.view addSubview:_drawDrawView];
    if(!_drawDrawView.scene) {
        _drawDrawView.ignoresSiblingOrder = YES;

        // Create and configure the scene.
        _scene = [GameScene unarchiveFromFile:@"GameScene"];
        _scene.scaleMode = SKSceneScaleModeAspectFill;

        // Present the scene.
        [_drawDrawView presentScene:_scene];
    }
}

3)在GameScene.m中显示“hello world”以及SKEmitterNode:

-(void)didMoveToView:(SKView *)view {
    /* Setup your scene here */
    SKLabelNode *myLabel = [SKLabelNode labelNodeWithFontNamed:@"Chalkduster"];

    myLabel.text = @"Hello, World!";
    myLabel.fontSize = 65;
    myLabel.position = CGPointMake(CGRectGetMidX(self.frame),
                                   CGRectGetMidY(self.frame));

    [self addChild:myLabel];

    NSString *fireEmmitterPath = [[NSBundle mainBundle] pathForResource:@"magic" ofType:@"sks"];
    SKEmitterNode *fireEmmitter = [NSKeyedUnarchiver unarchiveObjectWithFile:fireEmmitterPath];
    fireEmmitter = [NSKeyedUnarchiver unarchiveObjectWithFile:fireEmmitterPath];
    fireEmmitter.position = CGPointMake(self.frame.size.width/2, self.frame.size.height/2 - 200);
    fireEmmitter.name = @"fireEmmitter";
    fireEmmitter.zPosition = 1;
    fireEmmitter.targetNode = self;
    fireEmmitter.particleBirthRate = 100;
    [self addChild: fireEmmitter];
}

0 个答案:

没有答案