Moving shapes Using Keyboard

Official forum for the Chipmunk2D Physics Library.
Post Reply
tukhrejul
Posts: 2
Joined: Mon Jul 13, 2009 5:24 am
Contact:

Moving shapes Using Keyboard

Post 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?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Moving shapes Using Keyboard

Post 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.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests