简体   繁体   English

SpriteKit crossFadeWithDuration:场景之间没有按预期工作

[英]SpriteKit crossFadeWithDuration: between scenes not working as expected

I'm trying to perfrom a simple crossfade transition between scenes in my sprite kit project with the following code: 我正在尝试使用以下代码在我的精灵工具包项目中的场景之间进行简单的交叉渐变过渡:

SKTransition *crossFade = [SKTransition crossFadeWithDuration:1.0f];
[self.view presentScene:game transition: crossFade];

from a method of my main scene. 从我的主要场景的方法。

Here's what happens: 这是发生的事情:

  1. The game scene appears instantly over the current scene. 游戏场景立即显示在当前场景上。
  2. The game scene fades out in 1 second revealing the underlying current scene. 游戏场景在1秒内消失,显示出潜在的当前场景。
  3. The game scene appears instantly over the current scene. 游戏场景立即显示在当前场景上。

And here's what i expected to happen: 这就是我期望发生的事情:

  1. The game scene fades in over the underlying current scene 游戏场景在基础当前场景中淡入

I tested this also in other projects (like this one ) and i obtain the same behaviour. 我也在其他项目中测试了这个(比如这个 )并且我获得了相同的行为。

Is the transition working as intended or am I doing something wrong? 转换是按预期工作还是我做错了什么?

I had a very similar problem. 我有一个非常相似的问题。 Use a breakpoint and make sure you are only calling it once. 使用断点并确保只调用一次。 If it is in the update function or something similar then it could be being called twice. 如果它在更新函数或类似的东西中,则可以被调用两次。 If it's only called once, check the code in the Scene you're moving to. 如果只调用一次,请检查您要移动到的场景中的代码。 You might not initialise it properly and/or call the presentation of the previous scene. 您可能无法正确初始化和/或调用前一场景的演示文稿。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM