Tag Info

New answers tagged

1

First, when are you calling the jump() method? Make sure it really gets called, maybe by using a log message. Second, instead of body.setLinearVelocity(new Vector2(body.getLinearVelocity().x, 12)); you should do body.setApplyForce(new Vector2(0, 120)); Setting a velocity directly is frowned upon and should be done only in a few exceptional cases such ...


0

Just make sure your sprites aren't going outside the canvas if you don't want them to and I think it's fine. You'd just have to alter the boundaries for the bodies in relation to the canvas in that case.


0

To answer your question directly, no, you cannot change the anchor point dynamically. You only destroy the joint and re-create it. You should be able to change other joint parameters at run-time though. In real life the ride height of a car is determined by the equilibrium position reached by the springs: m*g = k*x where m is the mass of the car ...


0

I use and extended OrthographicCamera to fix this. package ferret.util; import com.badlogic.gdx.graphics.OrthographicCamera; /** * OrthographicCamera that cannot go beyond specified rectangle. */ public class BoundedCamera extends OrthographicCamera { private float xmin; private float xmax; private float ymin; private float ymax; ...


0

This sounds like a good use for a particle effect. When the fire is on, spawn multiple, small dots each frame. Assign a slightly different angle (generally facing downward) and slightly different velocity to each particle. Gradually change the color of each particle from yellow to dark-red over the course of its lifetime and remove it when it has reached ...


1

Bodies are made up of one or more fixtures and fixtures define a shape. This means, for each fixture, you need to get the shape and its size, then combine those to get the total width and height. It looks like the easiest way is with getRadius(), but that doesn't give you much. You may want to get the shape type, then create methods for getting more detailed ...


3

Simple Solution If you want the body to instantly rotate just call Body::setTransform and pass the current position and the desired angle, don't bother applying torques or anything. The function call could be something like this: body.setTransform(body.getPosition(),myDesiredAngle); Physics Solution If you want the player body to interact with bodies ...


0

I had similar problem with zoomed in rendering. I assume by "Box2D" render you mean Box2D debug renderer. Well, here is your problem. Before rendering debug data of Box2D, transform camera accordingly (add 0.5 or whatever, as you said) and after rendering Box2D debug stuff do the inverse transformation (subtract 0.5). I hope I understood your problem and my ...


2

NauticalMile's answer is great (and bonus points for the killer animated diagrams). To give an alternate suggestion that doesn't suffer from the same problems (the wheel collision stopping you from moving past objects that a floating body should be able to traverse effortlessly, I suggest modelling something more closely matched to the reality of your ...


11

Your question inspired me to play around with the RUBE editor to find a nice solution. Here's what I came up with: Setup 1 Let's start with the simpler one on the left. It has the following setup (from the bottom up): A wheel body that can roll back and forth A small box (chassis) attached to the wheel via a revolute joint. The chassis body is not ...


0

It is often advised to handle movements independent of the frame rate (since it will always vary at least a bit), as it will result in smoother transitions. So instead of hard-coding your desired value of "60", you could do the following instead: Calculate the movement you want to apply, e.g. per second. Divide that movement by the "time since the last ...


2

After all, everything was (almost) correct. The problem is you can't change the physics during callback. All I had to do was delay it to the next game cycle.



Top 50 recent answers are included