September 2018
Intermediate to advanced
434 pages
8h 47m
English
When the player contacts the Star, we will grant them invulnerability for a short time and give the player great speed to allow them to power through encounters. Follow these steps to implement the power-up:
Player.swift, add a new function to the Player class, as shown here: func starPower() { // Remove any existing star power-up animation, if // the player is already under the power of star self.removeAction(forKey: "starPower") // Grant great forward speed: self.forwardVelocity = 400 // Make the player invulnerable: self.invulnerable = true // Create a sequence to scale the player larger, // wait 8 seconds, then scale back down and turn off // invulnerability, returning the player to normal: let starSequence = SKAction.sequence([ ...Read now
Unlock full access