Capítulo 645 de 859

Chapter 645: Clock

Core Idea

Class for keeping track of time.

Key Concepts

  • autoStart : boolean: If set to true, the clock starts automatically when getDelta() is called for the first time.
  • elapsedTime : number: Keeps track of the total time that the clock has been running.
  • oldTime : number: Holds the time at which the clock's start(), getElapsedTime() or getDelta() methods were last called.
  • running : boolean: Whether the clock is running or not.
  • startTime : number: Holds the time at which the clock's start() method was last called.

Reference Tables

Constructor

Signature
new Clock( autoStart : boolean )

Properties

PropertyDescription
.autoStart : booleanIf set to true, the clock starts automatically when getDelta() is called for the first time.
.elapsedTime : numberKeeps track of the total time that the clock has been running.
.oldTime : numberHolds the time at which the clock's start(), getElapsedTime() or getDelta() methods were last called.
.running : booleanWhether the clock is running or not.
.startTime : numberHolds the time at which the clock's start() method was last called.

Methods

MethodDescription
.getDelta() : numberReturns the delta time in seconds.
.getElapsedTime() : numberReturns the elapsed time in seconds.
.start()Starts the clock. When autoStart is set to true, the method is automatically called by the class.
.stop()Stops the clock.

Key Takeaways

  1. Most relevant properties: autoStart, elapsedTime, oldTime, running.
  2. Key methods: getDelta, getElapsedTime, start, stop.

Connects To