Tag Info

Hot answers tagged

6

But I need to use images in the game as body... not shapes.. In Box2D, you will need to create shapes anyway, you can't really go without them. A body is composed of fixtures and a fixture is a shape, that's it. Here is the official Box2D manual if you want to read more about those concepts. anyone please explain me the steps to use images as a ...


5

Disclaimer: I have not used libgdx or Java before, this answer borrows syntax from the question and official documentation, and the code is untested To make the bodies 'fall' under the influence of gravity in box2d, you must first pass a non-zero gravity vector to the b2World when constructing the world World world = new World(new Vector2(0, -10), true); ...


4

The easiest way is to use a sensor instead a Body. A sensor generates a collision, but not a response. So you will be notified when they hit, but the hero will not bounce off.


3

Farseer is open source. http://farseerphysics.codeplex.com/SourceControl/changeset/view/94324#1436535 /// Warning: You cannot reuse fixtures. If you still want to do this, then try to reproduce some of the steps that Fixture.RegisterFixture() private method does.


3

Farseer does ship a physics view, and thankfully it requires very little brain power to implement and use. If you downloaded the "Farseer Physics Engine 3.3.1 Samples XNA" recommended package on their download page, you'd see a lot of examples included. Navigate to (or click these convenient links to the codeplex page :P) ...


2

Probably because it is a property and not a normal member variable. You need to change the entire tray.Position variable like this: tray.Position = new Vector2(tray.Position.X + delta.X, tray.Position.Y); Note that properties are a C# language feature. However this is what Farseer considers teleporting an object and this can interfere with the stability ...


2

If you are trying to destroy the body in a CollisonEvent, this happens mid-step so you can't do that. Your best bet is to build a list of objects you would like to destroy and have them removed next frame.


2

[Solution] This was a coding error on my part. Pointed out by a good reply above, I was updating the position of the sprite relative to the body and then stepping the physics. Thus never actually setting the sprite to the body's CURRENT position. Thanks!


2

I think I've managed to reproduce your problem - basically your friction is too high/your impulse not enough. Change your impulse from (-5, 0) to something like (-50, 0), and/or lower your friction coefficient. Seems to work... Also, on a side note, I wouldn't recommend instantiating and setting your InputProcessor every frame - do it once in your create() ...


2

You have to separate your physics simulation (bodies) from the graphical representation of the physics world. Lets assume you have a Box2d body defined like this float radius=3.0f; CircleShape shape=new CircleShape(); shape.setRadius(radius); FixtureDef fd = new FixtureDef(); fd.shape = shape; BodyDef bd = new BodyDef(); bd.type = BodyType.DynamicBody; ...


2

You haven't set any vertices on the shape. Create a new polygonshape and set the vertices of the shape using setAsBox or set(float[] vertices). Have a look at the documentation!


1

MouseJoint is not a good idea, it will get out of sync too. It's really meant to be used to make the body move towards the point. setTransform is exactly the same as setting the position and rotation of the Sprite. You just have to be setting the coordinates in meters not pixels. I am not an expert on multiplayer, but the latency will influence it always. ...


1

Farseer comes with a debugging environment. There's two ways of doing what you want to do. The first way is reproducing your situation in the test environment they ship. It will show everything of relevance. This is the technique I used for my game. The other way is to integrate the debugging environment they made into your game, this is slightly more ...


1

I'd go with spheres. When you grow, add new spheres to the existing ones (at different directions) more to the 'base spheres', less to the farther away ones, organized like this : Sphere B is 100 units from sphere A at "vector" 0.7 ; 0.3 ; -0.4 or just use the final vector 70.0 ; 30.0 ; -40 to connect B to A. You can even predefine the link points on ...


1

One is falling from the top and the other one which is static is at the button of the screen and is supposed to be used to catch the object that is falling. Sounds like you should use a kinematic body instead of a static one and adjust its velocity so that it moves towards the targeted location quickly when its far away and none at all when the x ...



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