Jump to content

P2 Toggle body.static state


Recommended Posts

Hey guys,

So I am currently working on a project where I have dynamic bodies constrained to static bodies through the use of createRevoluteConstraint so that the dynamic bodies only rotate where the static body is located. That part is working, now the next thing I want to be able to do is click and drag on the static bodies and move them to any point in game world and continue to have the dynamic bodies constrained to them.

I have this partially working by calling sprite.body.static = false when the mouse is clicked down and then sprite.body.static = true when the mouse is released. I also have the update function constantly calling sprite.body.static=true when the body is supposed to be static.

The issue I am running into is that when I release the mouse button the static body seems to drift in space based off how fast my mouse is moving when I release it. Gravity doesn't seem to have any effect on it though which is good.

So, does anyone have some ideas on how to go about fixing this? I want it to be completely static as soon as I release the mouse.


Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...