Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setDraggable does not work without adding a mouse joint #2

Open
catmanjan opened this issue Mar 19, 2014 · 3 comments
Open

setDraggable does not work without adding a mouse joint #2

catmanjan opened this issue Mar 19, 2014 · 3 comments

Comments

@catmanjan
Copy link

Not sure if this is how Box2D works, but adding
add(new B2FlxMouseJoint());

Makes setDraggable actually work. Why not just always add a mouse joint in B2FlxState?

@WingEraser
Copy link
Member

I didn't added that because of performance. Once you click on a box2d object it will go through some calculations. You can see it in B2FlxMouseJoint::mouseDown(). It needs to query all fixtures that may overlap the provided AABB. After that it needs to know whether the body is draggable or not.

My game uses box2d with a lot of bodies. The controls are just FlxButtons, but every time I press on the screen, it doesn't have to query all the fixtures.

@catmanjan
Copy link
Author

How about automatically adding a mouse joint (if one doesn't already exist) as soon as setDraggable is set to true on any body?

@WingEraser
Copy link
Member

Nope, ain't going to happen. I don't want any specific joint to be in B2FlxShape. It will also have some problem with multitouch support (if I ever managed to get that working properly). I need multiple mouse joints for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants