I am currently creating a game for a jam game hosted by my school using html, css, javascript and jQuery.
In this game, I use the countdown (which works great), but I would like it to lose 2 seconds when my character fell into the hands of enemies. When the countdown reaches 0, the player loses the game.
For this, I use "jChavannes" "github" ( link here ), which is really completed, but I cannot find a way to change the countdown while it works, although "jchavannes" uses many tools to use its work.
Here is the HTML code of what I would like to do, with buttons of what I need to change the countdown and javascript of what I use to make it all work (one library is missing, but it's way too big to be able to put here, you will find it on Github).
Is there an easy way to change the remaining time or is it just not designed to change without stopping and resetting?
var Example2 = new (function() { var $countdown, $form,
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="author" content="Jason Chavannes" /> <title>jQuery Timer Demo</title> <link rel="stylesheet" href="res/style.css" /> <script type="text/javascript" src="res/jquery.min.js"></script> <script type="text/javascript" src="jquery.timer.js"></script> <script type="text/javascript" src="res/demo.js"></script> </head> <body> <h3>Example 2 - Countdown Timer</h3> <span id="countdown">05:00:00</span> <form id="example2form"> <input type='button' value='Play/Pause' onclick='Example2.Timer.toggle();' /> <input type='button' value='Stop/Reset' onclick='Example2.resetCountdown();' /> <input type='text' name='startTime' value='300' style='width:30px;' /> </form> <div class='example-four'> <input type='button' value='timer.reset()' onclick='timer.reset();' /><br/> <input type='button' value='timer.once()' onclick='timer.once();' /><br/> <input type='button' value='timer.once(5000)' id="timerOnce5000" onclick='timer.once(5000);' /><br/> <input type='button' value='timer.set({time:1000})' id ="timerSetTime1000" onclick='timer.set({time:1000});' /><br/> <input type='button' value='timer.set({time:5000})' id="timerSetTime5000" onclick='timer.set({time:5000});' /> </div> <br/>
source share