Hello, I was trying to modify the Box2D library example called Collisions and Control, in order to remove the spring behavior and manipulate the box position only with the mouseX and mouseY values without having it bounce all around the screen.
Later I’m planing on using this behavior so i can do similar collisions using simpleOpenNI and a Kinect so users can hit the falling particles displayed on a screen using their hands.
But I haven’t been able to figure it out. When I remove the spring and get the box to use mouse position it loses its collision properties and particles just fall thru it.
I found that you need to change the update line to update the cube to the mouse position :
if (mousePressed) {
spring.update(mouseX,mouseY);
spring.display();
} else {
spring.update(mouseX,mouseY); // here
}
At first I tried to remove the random movement by commenting out the FixtureDef section in the Box class but it’s actually the code that add physics to the object. (the particles were falling through it)