Page 1 of 1

Moving shapes Using Keyboard

Posted: Mon Jul 13, 2009 6:21 am
by tukhrejul
Just I want to update the velocity of any shape if i press the left/right arrow key. Suppose, initially,the velocity of any shape is 0, if I press left key the velocity will be 200. How can I do this? please suggest me. Do I use cpUpdateVelocity or anotherway?

Re: Moving shapes Using Keyboard

Posted: Mon Jul 13, 2009 10:50 am
by slembcke

Code: Select all

body.v = cpv(vx, vy);
Just keep in mind that making large changes is velocity every frame can cause stability problems when colliding with other objects.