Why Does my SpriteKit Sprite Drop off the Screen?
You’re making a SpriteKit game. You have a sprite on the screen. You run the game, and the sprite falls off the screen. Why is this happening?
The answer is gravity.
If you add a physics body to a sprite, it is initially affected by gravity. Gravity is a downward force. The game launches, and the sprite moves down. Because there’s nothing in the scene to stop the sprite’s downward movement, it moves off the screen.
The fix is to set the physics body’s affectedByGravity
property to false.
sprite.physicsBody.affectedByGravity = false
Now the sprite will stay where you placed it.