I am making an iOS using Swift and SpriteKit. However I am experiencing irregularity in the running of my app. Sometimes the ship SKSpriteNodes doesn't appear on the screen, sometimes the bullet's SKSpriteNodes don't appear, sometimes everything shows up fine (I add the bullets elsewhere in the code). In all cases I am not making changes to the code between runs. I am starting the app on this screen directly so I'm thinking maybe it has something to do with these SKSpriteNodes not having enough time to initialize. Any ideas?
Set the zPosition
of the self.ship
so that it is in front of the background nodes. Something like this (I would do this after setting the position):
self.ship.zPosition = 1.0
You can also use negatives in the zPosition
, for instance, to drop the self.background
down. Think of zPosition
as layers (with support for decimals), the higher the number, the closer to the "top" of the layer stack your node will be.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With