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?
moving a shape with mouse
-
- Posts: 2
- Joined: Tue Feb 24, 2009 7:53 pm
- Contact:
-
- Posts: 56
- Joined: Tue Jul 15, 2008 4:13 am
- Contact:
Re: moving a shape with mouse
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.
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.
-
- Posts: 2
- Joined: Tue Feb 24, 2009 7:53 pm
- Contact:
Re: moving a shape with mouse
I don't want use the joint-metod because i don't want rotation during the drag. I want a simply translation
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: moving a shape with mouse
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/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 2
- Joined: Thu Mar 12, 2009 8:38 am
- Contact:
Re: moving a shape with mouse
Hi,
Rotation is impossible if you attach the joint to the center of any shape so choose the point where you click.
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]
Who is online
Users browsing this forum: No registered users and 8 guests