Search code examples
sprite-kitswift3xcode8gamekit

Nodes don't appear in iOS Simulator (GameKit)


Update: Even Apple's template code won't display nodes in the simulator.

The simplest of code, such as creating a red square node will not work (this project worked until today, and I haven't changed it). For example:

import SpriteKit
import GameplayKit

class GameScene: SKScene {

    override func didMove(to view: SKView) {

        let myNode = SKSpriteNode(color: UIColor.red, size: CGSize(width: 300, height: 300))

        myNode.position = CGPoint(x: 0, y: 0)

        self.addChild(myNode)
    }

}

Or more complicated code such as:

import SpriteKit
import GameplayKit

class GameScene: SKScene {

    let myNode = SKSpriteNode(imageNamed: "Spaceship.png")

    override func didMove(to view: SKView) {

        myNode.position = CGPoint(x: 0, y: 0)
        myNode.xScale = 0.5
        myNode.yScale = 0.5

        let action = SKAction.rotate(byAngle: 2, duration: TimeInterval(2))

        myNode.run(SKAction.repeatForever(action))

        self.addChild(myNode)

    }

}

Solution

  • For some reason either changing the project name in general, or changing it to not include a dash fixed it. I thought I would post this in case anyone else has this problem.