Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SKEmitterNode particleAction not working iOS9 Beta

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];

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!

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

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?

like image 611
user2821647 Avatar asked Sep 28 '22 04:09

user2821647


2 Answers

iOS9 SKEmitterNode targetNode property problem.

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.

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

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

like image 54
Michael Kennedy Avatar answered Oct 06 '22 01:10

Michael Kennedy


Can confirm this on iOS 9 beta 5. .particleAction seems to have stopped working completely! Hoping Apple fix in the next beta/GM build.

One of my new games rely on this so a little nervous at the moment!

like image 21
HarryGT Avatar answered Oct 06 '22 01:10

HarryGT