Quick tip - how to get a consistent speed using transition.to

Here's some things other readers here might find helpful. I'm a newbie with Corona and shouldn't be posting tips :-) but this code has helped me a lot this week. This is just my method that has worked.

The problem: If you're moving an actor on the stage between points, you'll get inconsistent speeds over different distances. As transitions are time based, a character will speed over a short distance and take longer to move over a longer distance.

Here's the code you'll need to move an actor using transition.to over any distance with a consistent pace. In this example, actor_name has to move to a display_image target_image. Target image can be set when someone clicks.

1) Add a speed setting:

1
2
-- number of pixels to move per second
actor_speed = 100;

Hey there,

Thanks for sharing this, I am sure a lot of people will find it very handy!

Peach :)

I was looking for a way to do that! Thanks!

xFactor & yFactor is really dX, dY, or distanceX, distanceY.

views:1489 update:2011/9/30 9:15:39
corona forums © 2003-2011