Hi.
I have got some help in another forum.
Where someone wrote the following:
Can someone please comment if it seams like the way to do it?
Hi Thome, welcome abroad...
I'm no expert but I have an idea to solve your problem..
what you need is AnimatedSprite class or AdvanceSprite class from GTGE for the road...
oh my bro solar, don't scare us with 3D stuff here Laughing , there you go you scared Thomas already...Laughing
yes the road basically is just like a triangle, in my mind there are minimum 6 frame for the road
animation. (the more frame the road has, the more smooth the animation)
the first 2 frame is for the straight road, called it A1 & A2
the different between A1 & A2 is the size & the position of the short stick & the center stripes you
mentioned, so if you animate it , the car just like moving forward. use this method in GTGE:
Code:
getAnimationFrame.setDelay(...)
with this mehotd you can set the car is going fast or slow. It only update the animation for the road
more faster or slower.
the 3rd & 4rd frame, called it A3 & A4 , is turn left road, just make the 2 curve line to the left so
it appear like a road, and give short stick & center stripes with different size & position, the more
it appear closer offcourse the more big the size of the short stick & the center stripe, so when you
animate it the car just like moving forward.
you can quest the last 2 frame right... it just like the 3rd & the 4rd frame, but only curve to the
right.
using AnimatedSprite or AdvanceSprite you may choose for the turn left or turn right behaviour you
like, between moving the road sprite or just simply moving the car sprite.
also you can manage the colision between the car with boundary(short sticks)
with AnimatedSprite class you can set which frame is currently active using method :
Code:
setAnimationFrame(0, 1) //straight road
setAnimationFrame(2, 3) //turn left road
setAnimationFrame(4, 5) //turn right road
say it you are using Timer class to manage when the road going to turn left or right ...you can use the
action method :
Code:
if(timer.action(elapsedTime)){
setAnimationFrame(2, 3)
}
there you go the simple way to create car simulator in 2D
if you don't understand or confuse with my explanation, please don't be hesitate to ask.
and for anyone who understand what I'm talking about, especially solar Razz , please help me for explaining more detail.