How to keep SKActions running through an SKTransition in Sprite Kit?

帅比萌擦擦* 提交于 2019-12-13 00:48:54

问题


I have tried the following code when trying to transition between scenes in my Sprite Kit project:

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
    XYZGameScene *gameScene = [[XYZGameScene alloc] initWithSize:CGSizeMake(self.size.width, self.size.height)];
    crossFade = [SKTransition fadeWithColor:[UIColor blackColor] duration:2];
    [playButtonSprite runAction:changePlayButtonTextureOFF];

    if(toGameAction){
        [self.scene.view presentScene:gameScene transition:crossFade];
    }else{}
}

The problem is, when I press the button that triggers the TRUE with toGameAction and the transition begins, the SKActions I have which are moving some objects in the background stop. Which isn't what I want. I am trying to make the transition between the two scenes seamless. As the backgrounds are the same just that one scene is the menu and the other is the actual game.

If you are having trouble with understanding what I am trying to implement, it's essentially when you press the button in Flappy Bird and the background doesn't stop moving through the transition between the menu and the game.


回答1:


SKTransition has a property for this named pausesOutgoingScene that has a default value of YES. All you have to do is set this property to NO.

crossFade.pausesOutgoingScene = NO;


来源:https://stackoverflow.com/questions/24891863/how-to-keep-skactions-running-through-an-sktransition-in-sprite-kit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!