How do I get accurate counting? My game has is a pass or fail scenario based on time. I need an equation that will work in ActionScript.
'Commence escape within 30 sec or lose 600 life points'
...you see only readout of lifepoints
, but time needs to be accurate
I'm not attached to this, it's just an example
var CURRENTCOUNT:int = 0;
var EQUA:int;
//WHERE I WANT TO PUT LINEAR EQUATION
EQUA = 34;//<==EQUATION GOES HERE???
var SPEED:int;
SPEED = EQUA;
var COUNTDOWN:Number = 600;
var COUNTUP:Number = 0;
//TIMER
var myTimer:Timer = new Timer(SPEED,600);
myTimer.addEventListener(TimerEvent.TIMER,someFunction);
myTimer.start();
//INCREMENTING++
function someFunction(event:TimerEvent) {
//COUNTDOWN stops count going down, COUNTUP stops count going up
CURRENTCOUNT = COUNTDOWN - myTimer.currentCount + COUNTUP;
//Testing with only a text string to rule out cashing issues
tx.text = String (Math.abs (CURRENTCOUNT));
}
I've tried this
SPEED=DISTANCE/TIME
In place of currentCount
, but it's not any more accurate. It adds acceleration
//VoVf
V++;
COUNT = V*V/X;
30 seconds and 600-0 lifepoints and counting I wanted to explain, 开发者_JAVA百科because it's not a clock. It's pass or fail. They look at there life drifting away.
Description of lifecount. Scene with Death holding a steampunk style timer or gauge and laughing:
- Player has so many seconds to escape '30 seconds
- Lifecount displays loss of players total life '600
- Player can choose between more power or more life if they make it out alive
These links can explain. They go over delta time and explain ideas useful for accurate counting and scoring. I hope this gets you started.
http://www.emanueleferonato.com/2007/02/19/flash-simple-timercountdown/
http://www.allquests.com/question/2589182/how-to-pause-game.html
http://www.kongregate.com/forums/4/topics/1773
http://www.kirupa.com/forum/archive/index.php/t-286177.html
精彩评论