Playing with SpriteKit in a Swift Playground - Update
/Things have changed a lot since I wrote "Playing with SpriteKit in a Swift Playground", so I thought it was worth writing an updated post, with an updated playground to download.
As I did before, here's the minimal content you need to get a SpriteKit scene and view in a live-view in the playground...
//SpriteKit and XCPlayground are required modules import SpriteKit import XCPlayground //Basic dimensions that we will use more later let frame = CGRect(x: 0, y: 0, width: 320, height: 256) let midPoint = CGPoint(x: frame.size.width / 2.0, y: frame.size.height / 2.0) //Create a scene, add something to it var scene = SKScene(size: frame.size) let nyanCat = SKSpriteNode(imageNamed: "Nyancat") nyanCat.position = midPoint nyanCat.setScale(8.0) scene.addChild(nyanCat) //Set up the view and show the scene let view = SKView(frame: frame) view.presentScene(scene) XCPlaygroundPage.currentPage.liveView = view
However, Playgrounds are now self documenting so please feel free to download the playground and work through the multiple pages that climax in a Swift SpriteKit tribute to Nyan Cat.