ios7 - 我如何从 UIViewController 移动到 myScene?

标签 ios7 xcode5 sprite-kit

我有 2 个 View Controller 。在第一个 View Controller 中,有游戏的介绍和 Logo ,在第二个 View Controller 中,它加载了 skscene。我通过单击按钮从我的第一个 View Controller 移动到第二个 View Controller 。但它成为错误。我的代码在第二个 View Controller 中是:

@interface MPAPViewSceneController()

@property (nonatomic, retain) MPAPMyScene *targetScene;
@property SKView *spriteView;
@end



- (void)viewDidLoad
{
  [super viewDidLoad];

 _spriteView = (SKView *)self.view;
 _spriteView.showsFPS = YES;
 _spriteView.showsNodeCount = YES;
 _spriteView.showsDrawCount   = YES;
}

-(void)viewWillAppear:(BOOL)animated {
  self.targetScene = [[MPAPMyScene alloc] initWithSize:CGSizeMake(768.0f, 1024.0f)];
 [_spriteView presentScene:self.targetScene];
}

 -(void)viewDidDisappear:(BOOL)animated 
{
  [super viewDidDisappear:YES];
  self.targetScene = nil;
}

在场景中我编写了下面给出的代码:

@interface MPAPMyScene()

@property (nonatomic) BOOL contentCreated;

@end

@implementation MPAPMyScene

-(void)didMoveToView:(SKView *)view {
if (self.contentCreated == NO) {
    [self createSceneContents];
    self.contentCreated = YES;
}
}



-(void)willMoveFromView:(SKView *)view {
[self removeAllChildren];
}


-(void)createSceneContents {
self.backgroundColor = [UIColor blueColor];
self.scaleMode = SKSceneScaleModeAspectFit;
}

最佳答案

尝试改变这个

_spriteView = (SKView *)self.view;

_spriteView = (SKView *)self.targetScene;

关于ios7 - 我如何从 UIViewController 移动到 myScene?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19268771/

相关文章:

ios - 如何为多个 UITextfields 使用单个 IOS UIDatePicker 对象

ios - 将 Parse.com 导入 Xcode 的 Prefix.pch 的导入类生成错误

swift - 如何在 XCode 中编写 OpenGL ES 片段着色器?

swift - 赋予 SKNode 自己的物理特性

当从链接安装应用程序时,iOS 应用程序传递特定的 ID

ios - UICollectionView 神秘崩溃

ios7 - 为什么当我运行 xcode 时 CPU 使用这么多

ios6 - 当编译器设置为 LLVM 5.0 时,iOS xCode5 不支持的编译器 'com.apple.compilers.llvmgcc42' 错误

cocoa - 针对 OS X 10.6 的 Xcode 5 开发

ios - 如何在 SpriteKit Swift 中只要我触摸就重复操作,当我停止触摸时操作停止