Tag Info

Hot answers tagged

3

This is less a problem with Box2dLights, and more a problem with setting up Box2d collision fixtures to match your sprites. The Box2dLight rays are colliding with the CircleShape fixture you attached to the box2d body. CircleShape chain = new CircleShape(); chain.setRadius(10); Instead, this should be a Polygon shape with the same dimensions as your box, ...


1

I'm assuming that you may be doing setTransform() on PBox to move the player around based on mouse positions. If that's the case, it is bound to happen, since setTransform occurs outside of the physics calculations. Consider adding a Joint to drag the pBox around (with large force).


1

Create static bodies A and B, each of them with rectangular fixtures with b2Fixture::setSensor(true). Utilize the b2ContactListener::BeginContact and b2ContactListener::EndContact to determine when a body is entering or leaving areas A or B. When one of these events is detected, modify the gravityScale of the dynamic body accordingly. In pseudocode these ...


1

Your car is slipping for the same reason that a car hanging up-side down, riding the ceiling, with 100% friction would slip. 100% friction roughly means that 100% of the force exerted via the wheels on the terrain is used to counter movement perpendicular along the normal of the terrain. But this force still isn't enough to counter the force of gravity. This ...


1

As I understood your question, you want to get the coordinates of the points of your body relative to the world, in other words, following the transformations applied to the body. I did this function not long ago, I hope this will help you and guide you towards an answer: public Vec2[] getPoints() { Vec2[] v = new Vec2[shape.getVertexCount()]; for ...


1

Why calculate the trajectory for the sounds/slow down effects? If you split the act of slowing down the camera and playing effects into sections upon approach to your squishy victim then you can essentially play them on condition of their proximity. This is a great example that comes to mind. The proximity slow down effects employed in Peggle The ball ...


1

If you have sleeping allowed (and the b2_timeToSleep is sufficiently short for your needs) you can use the b2Body::isAwake function to test if a rock is settled. Pseudo-code: For body in bodies: If(body is rock and not body->isAwake()) Then //Apply impulse End If End loop


1

As per Andy's comment: Nevermind, I fixed it. I just had to take out the p.setCenterX(center.x);p.setCenterY(center.y); out of the render function.



Only top voted, non community-wiki answers of a minimum length are eligible