For my game i need to create a timer to just let the user play for a limited time. since this project is just to let user know about the technology and experience how fantastic it will be that we are able to control and interact with our personal mobile devices.
While searching online to find how to create a timer with java script, I was guide to this specific website from Google.
From this website i am able to copy and modified my personal timer from here. As always i am will start in new working files to test is it the code i want then only bring in to my actual working files.
I am going make my game duration around 1 minute to 1 minute 30 seconds, so for var i use 90 then the var minutes = Math.round(second-30)/60 with round out to the time i want then when it is being trigger it will minus when it reach 0:00 the will stop the timer and show the player they had win the game.
This is the code in html inside body.
And i code style the CSS to make it appear like the image below.
So that is how i get my game timer.
References
Phpjabbers.com,. 'Javascript Countdown Timer | Javascript Tutorial'. [online] Available at:http://www.phpjabbers.com/javascript-countdown-timer-php46.html [Accessed 29 Dec. 2014].
No comments:
Post a Comment