gpt4 book ai didi

ios - SKEmitterNode particleAction 不工作 iOS9 Beta

转载 作者:可可西里 更新时间:2023-11-01 04:43:38 24 4
gpt4 key购买 nike

我正在 iOS9 Beta 4 中测试我的应用程序,发现许多曾经在 iOS8 中运行的代码不再按预期运行。另一个例子是 SpriteKit 的 SKEmitterNode“particleAction”属性。以下代码在 iOS8 中有效,但在 iOS9 中无效:

// create the particle movement action
SKAction *move = [SKAction moveByX:100 y:100 duration:5]; // also, I've tested several other SKActions, such as scaleBy, fade, rotate, to no effect here

// create a target node and add to the SKScene
SKNode *targetNode = [SKNode node];
targetNode.position = origin;
[mySKSceneNode addChild:targetNode];

// add an emitter node that has a target and an SKAction
SKEmitterNode *flameTrail = [NSKeyedUnarchiver unarchiveObjectWithFile:[[NSBundle mainBundle]pathForResource:@"FlameAttack" ofType:@"sks"]];
flameTrail.position = origin;
flameTrail.particleAction = move; // TODO iOS9 compatibility issues!
flameTrail.targetNode = targetNode;
[mySKSceneNode addChild:flameTrail];

在 iOS8 上,上面的代码会产生一个看起来像 Spark 飞舞的 SKEmitterNode。在 iOS9 上,SKEmitterNode 是完全不可见的(根本不出现在 SKScene 中)。如果我注释掉以下行:

flameTrail.particleAction = move; // TODO iOS9 compatibility issues!

然后我会在场景中看到 SKEmitterNode,但我不会看到任何与粒子相关的运动。

我还使用其他几个 SKActions 对此进行了测试,结果没有发现任何变化。我向 Apple 提交了一个错误;与此同时,任何人都可以确认/否认这个问题或在代码中看到问题吗?

最佳答案

iOS9 SKEmitterNode targetNode 属性问题。

当设置了 targetNode 属性时,粒子将在 zPosition 0 处发射。如果将 zPosition 设置为其他任何值都没有关系,粒子仍将在 zPosition 0 处渲染。如果将 zPosition 的值打印到控制台它会报告你设置的任何内容。如果您设置 targetNode = nil,粒子将渲染在正确的图层上。

解决方法:我将所有背景 Sprite 重新排序为 <= -1

希望这对您有所帮助,我将提交一份错误报告,同时我还在 github 上添加了一个示例存储库。 https://github.com/fromkey/iOS9_BUG_SKEmitterNode_targetNode/tree/master

关于ios - SKEmitterNode particleAction 不工作 iOS9 Beta,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31714076/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com