How to limit speed?

Hello!

I have an sprite which i have applyForce on and it works great until i hit my button to long then it just speeds up really fast. This isn't strange because i have a timer that tells it to applyForce every 150 ms but now i was looking for a way set up a maxspeed?

Does anyone have some tips how to do this? i might just have missed how to fetch the actual speed of the sprite ?

Kind regards

I think what's happening is every time you click the button, you make a new timer. So instead of it applying force every 150ms, it's applying every 150ms + however many times you click the button. Would you be able to post some of your code? Maybe only apply force to the sprite while your finger is down on the button.

Hey dacriburdan!

Its exactly how i am doing it=) I'm not at home now but how i does it is that on touch i start an timer and on release i stop the timer.

And i don't press the button several times i just hold it in, i think that is how it should be, can post some code later:)

/Inkoqnito

You are using applyForce, which stacks. You can set a max speed by getting the linear velocity and then if it is > X then = Y, etc, etc.

Peach :)

views:1432 update:2011/10/19 14:58:09
corona forums © 2003-2011