Transitions in SpriteKit does not work

I have a scene that calls the following using a transition like this:

  SKTransition *transition = [SKTransition revealWithDirection:SKTransitionDirectionDown duration:0.5];

  SKView *skView = (SKView *)self.view;

  SKScene * scene = [[GameOverScene alloc] initWithSize:self.size];
  scene.scaleMode = SKSceneScaleModeAspectFill;
  [skView presentScene:scene transition:transition];

Elements that make up GameOverScene(buttons, images, etc.) are added by the method init.

The problem is that the transition is not observed. One scene immediately goes to another.

I assume that the transition occurs before the next scene can create its own elements. I tried to move the creation of the next scene to didMoveToViewwithout success.

For testing purposes, I tried to delay the line presentSceneat times even more than 2 seconds. When I do this, I barely see the final frames of the transition.

How can I do it? What is the right way to build the next scene and perform the transition process.

+4
2

, .. , . , , , , . , , 2 , 0,5 .

? . . Apple Docs.

+ (void)preloadTextures:(NSArray *)textures withCompletionHandler:(void (^)(void))completionHandler

SKSprite, SKTexture "image.png". SKSprite texture ( background color) size. SKTexture . , ( "image.png" ) SKTexture.

: SKTexture, , . .

, , , . ( ) : SO sktexture-preloading.

+3

, . :

- (void)showGameOverScene
{
    SKTransition* reveal = [SKTransition doorsCloseVerticalWithDuration:0.5];

    SKScene* gameOverScene = [[RSGameOverScene alloc] initWithSize:self.size];

    [self.view presentScene:gameOverScene transition: reveal];
}

. , :

scene.scaleMode = SKSceneScaleModeAspectFill;

RSGameOverScene -(id)initWithSize:(CGSize)size, . .

, , , , . , - .

0

Source: https://habr.com/ru/post/1529672/


All Articles