moving a shape with mouse

Official forum for the Chipmunk2D Physics Library.
Post Reply
nongio
Posts: 2
Joined: Tue Feb 24, 2009 7:53 pm
Contact:

moving a shape with mouse

Post by nongio »

hi all,
i'm searching the way to move a shape with mouse. I've seen that the default method to drag an object is to use a Joint between the target body linked to a shape and a body without a shape, then set the position of the second body.
I would know if it's possible to manage the object drag directly by the setting it's position.
I've tried to realize this on my own, but unfortunatly it goes right only for few seconds, then the shape doesn't collide with others. Why?
ker
Posts: 56
Joined: Tue Jul 15, 2008 4:13 am
Contact:

Re: moving a shape with mouse

Post by ker »

Setting the object's position directly is not very stable, because it will mess up the velocity calculations.

It not colliding anymore doesn't make any sense thou. I think it would be much easier to find your problem if you would post your source code here. Are you sure it won't start colliding again if you hold the object steady for a while?

Why don't you want to use the joint-method? There's even an easy to use cpMouse "object" somewhere in this forum.
nongio
Posts: 2
Joined: Tue Feb 24, 2009 7:53 pm
Contact:

Re: moving a shape with mouse

Post by nongio »

I don't want use the joint-metod because i don't want rotation during the drag. I want a simply translation
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: moving a shape with mouse

Post by slembcke »

If you attach the joint to the center of gravity of the shape instead of at the point you clicked, you won't get any rotation.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
sksmith
Posts: 2
Joined: Thu Mar 12, 2009 8:38 am
Contact:

Re: moving a shape with mouse

Post by sksmith »

Hi,


Rotation is impossible if you attach the joint to the center of any shape so choose the point where you click.
[url=http://www.mag-corp.com/mag_services_offshore.asp]Offshore Software Development[/url]|[url=http://www.mag-corp.com/mag_services_custom.asp]Custom Software Development[/url]|[url=http://www.mag-corp.com/mag_services_itoutsourcing.asp]Software Outsourcing[/url]
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests