coal175
coal175

Reputation: 273

Scene isn't filling screen when recreating gameScene to restart game

So I am working on a sprite kit game and in didContactBegin, I have:

SKScene* myScene =[[GameScene alloc]initWithSize:self.size];
SKTransition* reveal = [SKTransition doorwayWithDuration:.5];
reveal.pausesIncomingScene = YES;
[self.view presentScene:myScene transition:reveal];

This works almost perfectly except for the fact that it does not completely fill back up the screen as it did on its first run and everything is scaled a little smaller. The x axis is completely filled but there seems to be a little bit missing on the top and bottom.

before game restarts after game restarts

Why is it different? It is the same code so shouldn't it do the same thing? Thanks!

Upvotes: 1

Views: 37

Answers (1)

giorashc
giorashc

Reputation: 13713

you need to set the scene's scale mode as you do when the view controller is first loaded:

SKScene* myScene =[[GameScene alloc]initWithSize:self.size];
myScene.scaleMode = SKSceneScaleModeAspectFill; // Use here the value you used in the view controller when creating the scene for the first time

Upvotes: 2

Related Questions