我正在使用转换从一个SKScene切换到另一个SKScene(这是scene.m中的代码):
-(id)initWithSize:(CGSize)size {
if (self = [super initWithSize:size]) {
/* Setup your scene here */
self.backgroundColor = [SKColor whiteColor];
SKSpriteNode *logo = [SKSpriteNode spriteNodeWithImageNamed:@"logo"];
logo.position = CGPointMake(self.size.width/2, self.size.height/2);
[self addChild:logo];
SKAction *pause = [SKAction waitForDuration:1.5];
[self runAction:pause completion:^{
MainMenuScene *mainMenu = [[MainMenuScene alloc] initWithSize:self.size];
SKTransition *fade = [SKTransition fadeWithColor:[SKColor whiteColor] duration:2];
[self.view presentScene:mainMenu transition:fade];
}];
}
return self;
}
在我的视图控制器中,我有这段代码:
-(void)viewWillLayoutSubviews
{
SKView * skView = (SKView *)self.view;
// Create and configure the scene.
SKScene * scene = [LogoScene sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
// Present the scene.
[skView presentScene:scene];
}
但是我希望我的新场景(MainMenuScene)能够设置自己的视图控制器。我真的不喜欢 知道,在使用转换时如何实现视图控制器的更改。有人可以给我看一段合适的代码。非常感谢。