I have got a timer of another website, when i try and intergrate the code into my timed game it doesnt output correctly.
This is what I have so far,
On the frame layer, first frame.
stop();
mbenneyTimer = function() {
this.reset();
}
//
mT = mbenneyTimer.prototype
//
mT.reset = function() {
this.oldTime = 0;
this.pause = true;
this.totalTime = 0;
}
mT.stop = function() { if (!this.pause) {
this.pause = true;
this.totalTime += getTimer() - this.oldTime;
}}
mT.start = function() { if (this.pause) {
this.pause = false;
this.oldTime = getTimer();
}}
//
mT.getMili = function() {
var returnTime = this.totalTime;
if (!this.pause) { returnTime += getTimer() - this.oldTime; }
return returnTime;
}
mT.getSecs = function() {
var returnTime = this.totalTime/1000;
if (!this.pause) { returnTime += (getTimer() - this.oldTime)/1000; }
return Math.round(returnTime);
}
mT.getMins = function() {
var returnTime = this.totalTime/1000;
if (!this.pause) { returnTime += (getTimer() - this.oldTime)/1000/60; }
return Math.round(returnTime);
}
mT.getCount = function(secs) {
var returnTime = this.totalTime;
if (!this.pause) { returnTime += (getTimer() - this.oldTime)/1000; }
var count = secs - returnTime
return Math.round(count);
}
Then on a button to start the timer timing.
on (release) {
myTimer = new mbenneyTimer();
myTimer.start()
nextFrame();
}
Then on a button to stop the timer.
on (release) {
nextFrame();
myTimer.stop();
}
Then another button to show the time on a dynamic text box.
on (release) {
time = "" + myTimer.getSecs(); + " Seconds."
}
The dynamic text box says when click a number say 10 which i belive i the seconds but it doesn’t add anything like the seconds and overwrite if i try and add
myTimer.getMins();
I just get another single number.
Please help thanks in advance.