I've been searching this for a few days now and have come up short of the full answer. I'm playing with SpriteKit for the first time and I'm having trouble with a very simple game using a lot of resources. I know that PhysicsBodies take up resources but this seems excessive. Demo code below uses 70%+ simulator CPU. I know the simulator runs high but 70% CPU for just a sprite sitting on stage? The image is a transparent png-8, roughly 16 Kb in size, and 75 pixels wide.
import SpriteKit
import GameplayKit
class GameScene: SKScene, SKPhysicsContactDelegate {
override func didMove(to view: SKView) {
physicsWorld.contactDelegate = self
let spaceship = SKSpriteNode(imageNamed: "rocketship75")
spaceship.physicsBody = SKPhysicsBody(rectangleOf: spaceship.size)
spaceship.physicsBody?.collisionBitMask = 0
spaceship.physicsBody?.affectedByGravity = false
spaceship.position = CGPoint(x: 0, y: 0)
addChild(spaceship)
print("Loaded spaceship")
}
}
If I comment out the SKPhysicsBody then CPU drops to 0. Is this normal and expected or is there a much more efficient way of doing this?