3D Game Programming

(C. Jardin) #1
If you create a scoreboard with var scoreboard = new Scoreboard(), the following
methods are available:


  • scoreboard.score(42)—sets the current score in the game. This will replace
    any existing score. If no number is supplied, zero is used. If the score
    section of the scoreboard is not shown already, this will show it.

  • scoreboard.showScore()—shows the score section of the scoreboard.

  • scoreboard.hideScore()—hides the score section of the scoreboard.

  • scoreboard.getScore()—returns the current score in the game.

  • scoreboard.addPoints(10)—increases the score in the game by the specified
    number.

  • scoreboard.subtractPoints(10)—decreases the score in the game by the specified
    number.


Timer


This feature keeps track of the total time that has gone by in the game.


If you create a scoreboard with var scoreboard = new Scoreboard(), the following
methods are available:


  • scoreboard.timer()—starts the timer in the game. If the timer section of the
    scoreboard is not shown already, this will show it.

  • scoreboard.showTimer()—shows the timer section of the scoreboard.

  • scoreboard.hideTimer()—hides the timer section of the scoreboard.

  • scoreboard.stopTimer()—stops the timer from counting any more.

  • scoreboard.startTimer()—starts the timer counting.

  • scoreboard.resetTimer()—restarts the timer from zero.

  • scoreboard.getTime()—returns the number of seconds that have elapsed in
    the game.


Countdown


This feature keeps track of the total time that has gone by in the game.


If you create a scoreboard with var scoreboard = new Scoreboard(), the following
methods are available:

Appendix 2. JavaScript Libraries Used in This Book • 276


Prepared exclusively for Michael Powell report erratum • discuss

Free download pdf