Gal Shahar
Gal Shahar

Reputation: 2815

Fading out on spriteKit

I'm making a spriteKit game, and I am new to sprtieKit. I want to make the screen fade out when the game is over, all the screen. For example, my screen is blue, when you lose the game I want it to slowly become black. Can it be done someway? Thanks In Advance (:

Upvotes: 0

Views: 439

Answers (1)

WangYudong
WangYudong

Reputation: 4423

If you're going to stay at the current scene after everything faded out. Add this line when game is over:

[self runAction:[SKAction fadeOutWithDuration:2.0]];

The reverse action is fadeInWithDuration by the way.

If you're going to present a new scene after everything faded out. Present the newScene like this:

SKScene *newScene = [[NewScene alloc] initWithSize:self.size];
SKTransition *fadeOut = [SKTransition fadeWithDuration:2.0];
[self.view presentScene:newScene transition:fadeOut];

Upvotes: 3

Related Questions