Forum Discussion
JavaScript Timer Question
Please check the attached Storyline file. Although I usually prefer playing games on their native platforms rather than within authoring tools, I took the time to create a simple solution that may help you track game time effectively.
This setup includes a JavaScript timer that you can start, pause, and reset as needed. The main JavaScript code loads when the timeline starts. After that, you can control the timer by calling functions such as gameTimer.start(), gameTimer.pause(), and gameTimer.reset(). These functions can be triggered from buttons or other Storyline events.
In addition to that, I created a timerId variable, which I believe aligns with your original approach based on your script. The code ensures that a new timerId is generated each time the user clicks the start button. When the reset function is called, the timerId is cleared as well, so that a new timerId will be created the next time the start button is pressed.
Example:
Related Content
- 4 months ago