I’ve been banging my head against a wall today because of a weird error in my SpriteKit game. I have been very busy these days working on some projects and I had put my SpriteKit game on hold meanwhile, so today I decided to start working on it again.
To my surprise, I found that now the hero would suddenly start ignoring the platforms and just fall and die for no apparent reason. As I was coding the projectile emitter nodes, I initially thought that I had somehow messed up the code. So I started examining all changes I had done, got back to previous git commits, discarding changes, but couldn’t find the error. Damn, I even used time machine to get back to prior versions in a frantic attempt to discover what was going on.
Unfortunately, I couldn’t manage to find the problem. So I searched the web, and found some insights that led me to the answer. It seems that there is a bug in iOS 7.1 that would cause the SKSpriteNode to ignore the collisions and contacts (thus rendering its physics body useless) if you set the xScale of the node to -1. The fact is that I was actually using the xScale of the nodes to turn my creatures left (as this is the easiest way to have them face left without having to re-draw all my sprites), so I will have to disable this feature until Apple comes up with a solution.
I have filled a bug request with Apple and I am waiting to hear from them. Will let you know if I receive an answer. Are you facing the same issue? let me know in the comments.
Edit: As Akash points out in the comments, there is a fix that implies reinitializing and setting the properties of the physics body of a SKNode after setting the xScale. However, in some environments (like my game), with potentially dozens of nodes turning and changing direction every iteration, it is a bit of an overkill to re-create their physics body that frequently, so I hope Apple releases a solution quick.