I want to drag my character like dragging the skeleton on the game below.
http://dan-ball.jp/javagame/stickman/
After touchesBegan I tried to calculate the the vector difference of the character's body and the touch point, and then apply the force to the character's body unitl touchesEnded.
However, if I touch on the screen and don move, the character is flying around the touch point just like a satellite moving around a planet.
I know it is because the inertia of the body but I have no idea of how to get the things done.
How to have some "inertia feature" and at the same time can hold the body statically? Is there any example?
Thanks a lot!
dragging body problem
-
- Posts: 9
- Joined: Thu Dec 23, 2010 10:11 pm
- Contact:
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: dragging body problem
Chipmunk ships with a demo application that shows how to do mouse control. http://code.google.com/p/chipmunk-physi ... ?r=676#329
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: 9
- Joined: Thu Dec 23, 2010 10:11 pm
- Contact:
Re: dragging body problem
Thanks! That's great
Merry X'mas
Merry X'mas
-
- Posts: 9
- Joined: Thu Dec 23, 2010 10:11 pm
- Contact:
Re: dragging body problem
Another problem arise.
I have 4 static shape act as bounds on the screen edges. They are set to just fit the screen size.
When I drag the body with a circle shape using the above tech, the body will be stuck when it is on the corner (i.e. the contacting area of two adjacent bounds) and I can never drag it out.
The circle's radius is 15, and it's position is (14.8999XXX, 465.xxxxxxx), which means it has gone into the bounds for a little bit and cannot move anymore
I have 4 static shape act as bounds on the screen edges. They are set to just fit the screen size.
When I drag the body with a circle shape using the above tech, the body will be stuck when it is on the corner (i.e. the contacting area of two adjacent bounds) and I can never drag it out.
The circle's radius is 15, and it's position is (14.8999XXX, 465.xxxxxxx), which means it has gone into the bounds for a little bit and cannot move anymore
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: dragging body problem
I'm not quite sure why that would happen. The default allowed overlap in Chipmunk is 0.1, which is why the shapes overlap a little. Are you sure that the mouse joint is getting removed? If you forgot to do that, it could pin it in the corner.
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/
Who is online
Users browsing this forum: Heise IT-Markt [Crawler] and 12 guests