user3422148
user3422148

Reputation: 59

Switching scenes in Sprite Kit (Objective C) throws error

I am currently having issues switching scenes in Sprite kit. I am calling a method called "enterChurch" that switches scenes to the the churchScene. Here's the code:

-(void)enterChurch
{    
SKView * skView = (SKView *)self.view;

SKScene *churchScene = [SAFChurchScene sceneWithSize:skView.bounds.size];
churchScene.scaleMode = SKSceneScaleModeAspectFill;
self.curScene = churchScene;

[skView presentScene:churchScene];

}

When I run it, I get the error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setShowsFPS:]: unrecognized selector sent to instance

What am I doing wrong?

Upvotes: 1

Views: 296

Answers (2)

John Houston
John Houston

Reputation: 97

If I understood you correctly, you are trying to switch from one scene in Sprite Kit to Another Scene in sprite kit?

In that case use transitions.

In your current scene.h import ChurchScene.h (or whatever is name of your churchScene.h). Then add this to your method:

-(void)enterChurch
{
SKScene *church = [[ChurchScene alloc] initWithSize:self.size];
SKTransition *transition = [SKTransition fadeWithDuration:0]; //Use any time you like
[self.view presentScene:church transition:transition];
}

Hope this helps :)

Upvotes: 2

Eric Dufresne
Eric Dufresne

Reputation: 106

This is usually the cause of a UIView object calling a method that an SKView should be calling so it doesn't recognize the @selector. Check to see in your storyboard that the view inside the view controller is of type SKView. It should run

Upvotes: 0

Related Questions