View Full Version : how could I do this? (racing sim)
marckd
February 22nd, 2008, 03:35 PM
Hi there, I would like to do a sim racing, but I have no idea how to do it...
for example...
with only two competitors, the data will be loaded from a xml, this far 0k!
but I don't know how to do it, I know how to make the movement for only one, sending the time it tooked to go from a point to the other, but I don't know how to implement it with two or more competitors
for example for 100m, A tooked 10 seconds, and B tooked 9,8 seconds, so B won
but how do I represent that in the finish line?
thanks for your time
therobot
February 22nd, 2008, 05:03 PM
AS2? when the race starts, have a var called starttime...
var startTime = getTimer();
onEnterFrame = function ()
var currentTime = getTimer();
var elapsedTime = currentTime - startTime;
trace(elapsedTime);
//check to see if either player finished the race here, mark their time as elapsedTime.
}[/CODE]
marckd
February 22nd, 2008, 05:13 PM
AS2? when the race starts, have a var called starttime...
var startTime = getTimer();
onEnterFrame = function ()
var currentTime = getTimer();
var elapsedTime = currentTime - startTime;
trace(elapsedTime);
//check to see if either player finished the race here, mark their time as elapsedTime.
}[/code]
thanks for replying, and yes, AS 2
but, 0k... that gaves me the time, but doesn't creates the motion simulation
I want to keep the competitors in the screen, and make the background to move and that will create the movement effect, I can do it with only one competitor, but if I have two, then I don't know how to create the effect of different positions
for example
the background is 1000px width long, and the competitor A takes 5 seconds to get until 500px and another 6 to the whole 1000px
then, competitor B takes 4 seconds to 500px and 6 to the whole 1000px
with only one competitor, I just have to adjust the movement of the background and that is all, but with two or more it adds more complexity
so, how can I make this movement and race effect? is there any example, or maybe a simplier solution!?
thanks :)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.