ChallengeGameScene

class ChallengeGameScene : GameScene

An extended class of the game level scene dedicated to challenges.

Levels that use this subclass add extra components to track things such as steps taken, solution times, and costume changes. The purpose of this subclass is to provide extensions to the level for challenges for things such as achievements, leaderboards, and “advanced levels”.

  • The current time in this level.

    Declaration

    Swift

    public var currentTime: TimeInterval
  • A tuple of integers containing the number of times a player has switched costumes.

    The tuple is in the order: USB, Bird, Sorceress. The “default” costume is excluded.

    Declaration

    Swift

    public var costumeIncrements: (Int, Int, Int)
  • The total number of times a player has switched costumes.

    Declaration

    Swift

    public var totalCostumeIncrement: Int
  • Set up the scene and set the cached costume.

    Declaration

    Swift

    override func sceneDidLoad()
  • Run the standard level game loop and update the challenge states as necessary.

    Declaration

    Swift

    override func update(_ currentTime: TimeInterval)

    Parameters

    currentTime

    The current time when running the update.

  • Move to the next view and calculate the final challenge scores.

    Challenge scores are activated only when the player is near the exit and the exit is activated.

    Declaration

    Swift

    override func willMove(from view: SKView)
  • Run any challenge calculations after a given event.

    For levels with a time-based challenge, this method should be overridden to fit the appropriate calculations and grant any leaderboard status or achievement, respectively.

    For levels with a costume-dependent challenge (i.e., least amount of switches), this method should be overridden to account for these calculations.

    Important

    This method will automatically trigger when the scene moves (SKScene.willMove) and should not be called directly.

    Declaration

    Swift

    func willCalculateChallengeResults()
  • Send a Game Center notification to the player to show them their time scores.

    This method should most likely be called in ChallengeGameScene.willCalculateChallengeResults for maps with a timed leaderboard.

    Declaration

    Swift

    func announceTimeResults()