1
不改變我創建了一個遊戲,現在我想加入,我想運行一個視頻的開始屏幕,之後會出現與啓動按鈕的畫面,我已經搜查了互聯網,但找不到辦法,嘗試了很多東西,最新的代碼是:場景在SpriteKit
#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錯誤。你能告訴我怎麼做嗎?
請提供錯誤的詳細信息 – aramusss
終止應用程序(當它引起的,顯示錯誤文本等),由於未捕獲的異常「NSInvalidArgumentException」,原因:「*** - [NSPlaceholderdata initWithContentOfFile:選項:錯誤:]:無文件arguement」 – user3921943