whiteadi Posted March 1, 2014 Share Posted March 1, 2014 Hi, I try to reset the time game with: game.time.reset(); but it continues... Thanks,Adrian Link to comment Share on other sites More sharing options...
rich Posted March 2, 2014 Share Posted March 2, 2014 Yes all it does is reset the time at which the game time started, so things like Time.totalElapsedSeconds would give you a different value after the reset. Link to comment Share on other sites More sharing options...
whiteadi Posted March 3, 2014 Author Share Posted March 3, 2014 Hmm, ok, I was expecting also a different value for game.time.time ... Thanks,I think my implementation of the timer then needs to change Adrian Link to comment Share on other sites More sharing options...
whiteadi Posted March 3, 2014 Author Share Posted March 3, 2014 Changed it like this: ... function updateTimer() { end = new Date() diff = end - start diff = new Date(diff) milliseconds = diff.getMilliseconds() seconds = diff.getSeconds() minutes = diff.getMinutes() var hr = diff.getHours()-1 if (minutes < 10){ minutes = "0" + minutes } if (seconds < 10){ seconds = "0" + seconds } if(milliseconds < 10){ milliseconds = "00" +milliseconds } else if(milliseconds < 100){ milliseconds = "0" +milliseconds } timer.setText(minutes + ':'+ seconds + ':' + milliseconds); if(seconds>time_intervals[level]){ scoreText.x = game.world.centerX - 200; scoreText.font.fill = '#FF0000'; scoreText.content = 'You lost at level: ' + (level + 1) + '. Score: ' + score + '\nPress SPACE to restart.'; lost = true; resetTimer(); } } function chronoReset(){ resetTimer(); timer.content = '00:00:00'; start = new Date() } ... in the create I create a new start date start = new Date() and after that i start the first level and in the update the updateTimer will be called. works Link to comment Share on other sites More sharing options...
Recommended Posts