How to mimic a car left and right turn

Hi

I am looking for assistance on how to make the movement of the car to mimic a left and right turning. In the game, when you click the board, the car moves from one lane to another lane but its the whole body that shifts. What I am looking to achieve is when you touch the screen, the front of the car to move first then followed by the back so it appears the front tiers moves first

This is how my game looks

https://www.youtube.com/watch?v=OUKcJiSNTtI

This is what I would like

https://www.youtube.com/watch?v=_mLcuD2TDI0&feature=youtu.be

Below is code that controls the lane change:

if self.moving then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.x = self.x+self.moving; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if self.currentLane == 1 then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if self.x \<= lanesData[1] then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.moving = nil; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.x = lanesData[1]; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if self.x \>= lanesData[2] then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.moving = nil; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.x = lanesData[2]; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp; end

Thank you for your help

I don’t know if anyone could give me a hint on how this would work. I am new to corona and i know this might require a little of math. thanks

Use a set of transitions.

This code:

-- xR, xL - Pre calculated positions for the cars's right/left lane -- onComplete() not shown will flip car's flag: inLane from left to right. -- -- Each car has its own left and right lane. -- if( self.inLane == "left" ) then self.inLane = "right" transition.to( self, { rotation = 45, time = steerTime1, transition = easing.outCirc } ) transition.to( self, { rotation = 0, delay = steerTime1, time = steerTime2, transition = easing.inCirc } ) transition.to( self, { x = self.xR, time = laneTime, onComplete = onComplete } ) else self.inLane = "left" transition.to( self, { rotation = -45, time = steerTime1, transition = easing.outCirc } ) transition.to( self, { rotation = 0, delay = steerTime1, time = steerTime2, transition = easing.inCirc } ) transition.to( self, { x = self.xL, time = laneTime, onComplete = onComplete } ) end

is extracted from the sample in this video:

https://www.youtube.com/watch?v=3SachjJszBo&feature=youtu.be

You’ll have to grok what’s going on here, tear it apart, and fit it to your dev style

Hi Roaminggamer 

Thanks for the code. I am trying my very best to put this into my game but no luck. Don’t really know for how long i will finally get this working :frowning:

Well.  I’m going to release a kit sometime over the next few days that shows the entire game mechanics in its entirety.

I’ll post back then.

-Ed

Thanks Ed, please let me know when its out

I don’t know if anyone could give me a hint on how this would work. I am new to corona and i know this might require a little of math. thanks

Use a set of transitions.

This code:

-- xR, xL - Pre calculated positions for the cars's right/left lane -- onComplete() not shown will flip car's flag: inLane from left to right. -- -- Each car has its own left and right lane. -- if( self.inLane == "left" ) then self.inLane = "right" transition.to( self, { rotation = 45, time = steerTime1, transition = easing.outCirc } ) transition.to( self, { rotation = 0, delay = steerTime1, time = steerTime2, transition = easing.inCirc } ) transition.to( self, { x = self.xR, time = laneTime, onComplete = onComplete } ) else self.inLane = "left" transition.to( self, { rotation = -45, time = steerTime1, transition = easing.outCirc } ) transition.to( self, { rotation = 0, delay = steerTime1, time = steerTime2, transition = easing.inCirc } ) transition.to( self, { x = self.xL, time = laneTime, onComplete = onComplete } ) end

is extracted from the sample in this video:

https://www.youtube.com/watch?v=3SachjJszBo&feature=youtu.be

You’ll have to grok what’s going on here, tear it apart, and fit it to your dev style

Hi Roaminggamer 

Thanks for the code. I am trying my very best to put this into my game but no luck. Don’t really know for how long i will finally get this working :frowning:

Well.  I’m going to release a kit sometime over the next few days that shows the entire game mechanics in its entirety.

I’ll post back then.

-Ed

Thanks Ed, please let me know when its out