Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
292 views
in Technique[技术] by (71.8m points)

ios - Simple Sprite Kit Scene setup going wrong

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'.

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

Some code:

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'
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...