如何通过Sprite Kit中的SKTransition保持SKActions运行? [英] How to keep SKActions running through an SKTransition in Sprite Kit?

查看:54
本文介绍了如何通过Sprite Kit中的SKTransition保持SKActions运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在Sprite Kit项目中的场景之间切换时,尝试了以下代码:

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{}
}

问题是,当我按下用toGameAction触发TRUE的按钮并开始转换时,我拥有的SKAction停止了,这些SKAction在后台移动了一些对象.这不是我想要的.我试图使两个场景之间的过渡无缝.由于背景相同,只是一个场景是菜单,另一个场景是实际的游戏.

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.

推荐答案

SKTransition 具有一个名为pausesOutgoingScene的属性,其默认值为YES.您所要做的就是将此属性设置为NO.

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;

这篇关于如何通过Sprite Kit中的SKTransition保持SKActions运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆