Slide 11
Slide 11 text
class StartScene : SKScene {
let TITLE = "Game Title"
override func didMove(to view: SKView) { ... }
func createTitle() -> SKLabelNode { ... }
override func touchesBegan(_ touches: Set, with event: UIEvent?) {
let helloNode = self.childNode(withName: self.TITLE)
// Unwrap optional from helloNode
if let hello = helloNode {
// Prevent multiple actions
hello.name = "";
// Create actions
let zoom = SKAction.scale(to: 2.0, duration: 0.5)
let fadeAway = SKAction.fadeOut(withDuration: 0.5)
let remove = SKAction.removeFromParent()
// Create group of actions running in parallel
let parallel = SKAction.group([zoom, fadeAway])
// Create group of actions running in sequence
let sequence = SKAction.sequence([parallel, remove]);
// Run the action
// hello.run(sequence)
hello.run(sequence, completion: {
let gameScene = GameScene(size: self.size);
let transition = SKTransition.doorsOpenVertical(withDuration: 0.5)
self.view?.presentScene(gameScene, transition: transition)
})
}
}
}