简单的Sprite Kit场景设置出错了 [英] Simple Sprite Kit Scene setup going wrong

查看:124
本文介绍了简单的Sprite Kit场景设置出错了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置一个简单的Sprite Kit设置。
我正在做的是从'空应用程序'重新创建默认的xCode模板'Sprite Kit Game'。

I'm trying to set up a simple Sprite Kit setup. All I'm doing is re-creating the default xCode template 'Sprite Kit Game' from an 'Empty Application'.

它一直在崩溃 skView.showsFPS = YES; 行。哪个我无法解释。你可以吗?谢谢!

It keeps crashing on the skView.showsFPS = YES; line. Which I can't explain. Can you? Thanks!

部分代码:

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    (NSDictionary *)launchOptions
{
  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  MenuController *menuController = [[MenuController alloc] init];
  self.window.rootViewController = menuController;
  [self.window makeKeyAndVisible];
  return YES;
}

MenuController.m

- (void)viewDidLoad
{
  [super viewDidLoad];

  SKView *skView = (SKView *)self.view;
  skView.showsFPS = YES;
  skView.showsNodeCount = YES;

  MultiplayerView *gameView = [MultiplayerView sceneWithSize:skView.bounds.size];
  gameView.scaleMode = SKSceneScaleModeAspectFill;

  [skView presentScene:gameView];
}

当我启动它时,会发生以下错误:

When I launch this, the following error occurs:

2013-11-10 13:08:01.605 ByS[9419:70b] -[UIView setShowsFPS:]: unrecognized selector sent to instance 0x10c00bc60
2013-11-10 13:08:01.608 ByS[9419:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setShowsFPS:]: unrecognized selector sent to instance 0x10c00bc60'


推荐答案

在界面构建器中,将窗口视图的类更改为 SKView 。除非 UIView UIView 输入 SKView 将不会执行任何操作c $ c>之前是通过投射 SKView 获得的。

In the interface builder, change the class of the window's view to SKView. Type-casting a UIView into SKView won't do anything unless the UIView was previously obtained by casting a SKView.

这篇关于简单的Sprite Kit场景设置出错了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆