场景在SpriteKit中没有变化

时间:2015-08-25 13:09:02

标签: ios objective-c sprite-kit skscene

我已经创建了一个游戏,现在我想添加一个开始屏幕,我想在其中运行一个视频,然后会有一个带有开始按钮的屏幕,我已经通过互联网搜索但是找不到做到这一点的方法,尝试了很多东西,最新的代码是:

#import "FirstScreen.h"
#import "GameScene.h"
#import <MediaPlayer/MediaPlayer.h>

@implementation FirstScreen

-(id)initWithSize:(CGSize)size {
    if (self = [super initWithSize:size]) {
        NSURL *url =[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Intro" ofType:@"mp4"]];
        _player = [[MPMoviePlayerController alloc] initWithContentURL:url];
        _player.view.frame = CGRectMake(0,0, 1024, 768);
        [self.view addSubview:_player.view];

        _player.shouldAutoplay = YES;
        [_player prepareToPlay];

        NSString *nextSceneButton;
        nextSceneButton = @"Start";

        SKLabelNode *myLabel = [SKLabelNode labelNodeWithFontNamed:@"Chalkduster"];

        myLabel.text = nextSceneButton;
        myLabel.fontSize = 30;
        myLabel.fontColor = [SKColor blackColor];
        myLabel.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
        myLabel.name = @"Start";

        [self addChild:myLabel];
    }
    return self;
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    /* Called when a touch begins */
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInNode:self];
    SKNode *node = [self nodeAtPoint:location];

    if ([node.name isEqualToString:@"Start"]) {
        SKTransition *reveal = [SKTransition fadeWithDuration:3];

        GameScene *scene = [GameScene sceneWithSize:self.view.bounds.size];
        scene.scaleMode = SKSceneScaleModeAspectFill;
        [self.view presentScene:scene transition:reveal];
    }
}

@end

应用程序刚启动并给出SIGABRT错误。你能告诉我怎么做吗?

0 个答案:

没有答案