SKEmitterNode particleAction无法运行iOS9 Beta [英] SKEmitterNode particleAction not working iOS9 Beta

查看:121
本文介绍了SKEmitterNode particleAction无法运行iOS9 Beta的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS9 Beta 4中测试我的应用程序,并发现许多过去在iOS8中工作但不再按预期运行的代码。另一个例子是SpriteKit的SKEmitterNodeparticleAction属性。以下代码在iOS8中有效,但在iOS9上无效:

I'm testing my app in iOS9 Beta 4 and finding lots of code that used to work in iOS8 that is no longer performing as expected. Another example is SpriteKit's SKEmitterNode "particleAction" property. The following code worked in iOS8 but does not work on 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上,上面的代码会产生一个看起来像火花飞舞的SKEmitterNode。在iOS9上,SKEmitterNode是完全不可见的(根本不会出现在SKScene中)。如果我注释掉以下行:

On iOS8 the code above would yield an SKEmitterNode that looked like sparks flying. On iOS9 the SKEmitterNode is totally invisible (does not appear in the SKScene at all). If I comment out the following line:

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

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

then I will see the SKEmitterNode in the scene but I will not see any motion associated with the particles.

我还用其他几个SKA测试了这个,并没有看到结果有任何变化。我向Apple提交了一个错误;在此期间,任何人都可以确认/否认此问题或查看代码中的问题吗?

I've also tested this with several other SKActions and didn't see any change in results. I submitted a bug to Apple; in the meantime can anyone confirm/deny this problem or see a problem in the code?

推荐答案

iOS9 SKEmitterNode targetNode属性问题。

iOS9 SKEmitterNode targetNode property problem.

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

When the targetNode property is set the particles will emit at zPosition 0. It doesn't matter if you have set zPosition to be anything else, the particles will still render at zPosition 0. If you print the value of zPosition to the console it will report back whatever you have set it to. If you set targetNode = nil, the particles will render on correct layer.

解决方案:
我将所有背景精灵重新排序为< = -1

Solution: I reordered all my background sprites to be <= -1

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

hope this helps, I'm going to file a bug report, also I added an example repo on github. https://github.com/fromkey/iOS9_BUG_SKEmitterNode_targetNode/tree/master

这篇关于SKEmitterNode particleAction无法运行iOS9 Beta的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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