chracter running

i need to run my cycle right when i press the white rectangle but i need to run my cycle smothly when i press the rectangle button

after unpress the rectangle then it will stop slowly like real cycle…please let me know how i can do this because i,m new in corona.

please find attach

Have you figure it out? If not, this is my personal opinion.

For such animation, it would be easier to use sprite. This is a good tutorial: http://coronalabs.com/blog/2012/10/02/animated-sprites-and-methods/

And then i will use timer to slow down and stop the bike. You can use the documentation: http://docs.coronalabs.com/api/library/timer/index.html.

The idea is you run the animation on rectangle press, and start the timer to slow down to stop the animation on release.

Thanks wilychrostian,

i figure out the animation but i don,t understand how timer work please can you send me a example of code how i can do this?

also i use physic in my cycle (linearVelocity) so when i press my button cycle move and when unpress cycle stop but cycle not move perfectly like real cycle and not stop like real…this is just move and stop.

Sorry for slow response.
Linear velocity. Do you mean function object:setLinearVelocity( xVelocity, yVelocity )?
Well i never use it before. How does it work? Does obj:setLinearVelocity(5,0) move the obj 5 pixel to the right? If it does, then you can use it along with timer.
You can find some sample codes from link on my post before. Look up at timer:performWithDelay.
Here’s my idea:

  1. use xVeloc to move the bike.
  2. timer starts when button is released
  3. use timer to move the bike (call setLinearVelocity) while gradually reduce the xVeloc at the same time. When xVeloc is 0, stop timer and nil it.
    Sorry couldn’t write in lua for now. But the doc is good and easy to understand. Try some code and post them here later.

Have you figure it out? If not, this is my personal opinion.

For such animation, it would be easier to use sprite. This is a good tutorial: http://coronalabs.com/blog/2012/10/02/animated-sprites-and-methods/

And then i will use timer to slow down and stop the bike. You can use the documentation: http://docs.coronalabs.com/api/library/timer/index.html.

The idea is you run the animation on rectangle press, and start the timer to slow down to stop the animation on release.

Thanks wilychrostian,

i figure out the animation but i don,t understand how timer work please can you send me a example of code how i can do this?

also i use physic in my cycle (linearVelocity) so when i press my button cycle move and when unpress cycle stop but cycle not move perfectly like real cycle and not stop like real…this is just move and stop.

Sorry for slow response.
Linear velocity. Do you mean function object:setLinearVelocity( xVelocity, yVelocity )?
Well i never use it before. How does it work? Does obj:setLinearVelocity(5,0) move the obj 5 pixel to the right? If it does, then you can use it along with timer.
You can find some sample codes from link on my post before. Look up at timer:performWithDelay.
Here’s my idea:

  1. use xVeloc to move the bike.
  2. timer starts when button is released
  3. use timer to move the bike (call setLinearVelocity) while gradually reduce the xVeloc at the same time. When xVeloc is 0, stop timer and nil it.
    Sorry couldn’t write in lua for now. But the doc is good and easy to understand. Try some code and post them here later.