box2d

body falls slowly in any gravity

℡╲_俬逩灬. 提交于 2020-01-07 07:58:29
问题 I've created a World with earth gravity and I place an entity in the scene (contains a sprite and a Body) and it falls down slowly like a balloon. Here's how I set the World: world = new World(new Vector2(0, -GRAVITY_EARTH), true); and here's the relevant Box2D code for the Body etc: BodyDef bodyDef = new BodyDef(); bodyDef.type = BodyDef.BodyType.DynamicBody; bodyDef.position.set(positionX, positionY); // Create our body in the world body = world.createBody(bodyDef); // Grab the first idle

Box2D: How to get the position of a sensor?

我怕爱的太早我们不能终老 提交于 2020-01-06 16:50:50
问题 Edit I've updated this question here: Box2D: How to get the position of a static body? I'm using sensors in a Box2D project. On a collision with a sensor, I'd like to know the sensor's position in the world. I'm detecting the collision with a contact listener, but the sensor's position is always 0 0. From my code: (edit, added the whole class) public class MyContactListener extends b2ContactListener { public var onSensorEvent:Function; override public function BeginContact(contact:b2Contact)

Set contact enabled in box2d andengine

放肆的年华 提交于 2020-01-06 08:39:17
问题 How to disable the contact between two bodies in box2d (Andengine). I have used contact.setEnabled(false) but this was not working for me. I have given code below for reference. @Override public void beginContact(final Contact pContact) { final Fixture fixtureA = pContact.getFixtureA(); final Body bodyA = fixtureA.getBody(); final Object userDataA = bodyA.getUserData(); final Fixture fixtureB = pContact.getFixtureB(); final Body bodyB = fixtureB.getBody(); final Object userDataB = bodyB

why DirectionalLight is not casting shadow?

元气小坏坏 提交于 2020-01-06 05:34:35
问题 Code: Color color = new Color(1f,1f,1f,0.9f); DirectionalLight directionalLight = new DirectionalLight(rayHandler,200,color,-90f); directionalLight.setSoftnessLength(0); Result: When light falls directly from above, why it is not casting shadows from boxes? 回答1: This could be caused by a few things. Some things to check: Check if your RayHandler is set to blur. Blurring with small objects can hide shadows. Check the Shadows are enabled in the ray handler. Check the ambient light is off or

box2d(libgdx) stacked bodies not stable

柔情痞子 提交于 2020-01-06 02:58:42
问题 When I make a lot of bodies (rectangles) stacked on each other they don't stand stable. Even if restitution is set to 0. They are bouncy and fall off each other. I tried setting the density to a very low value, but it didn't change. Is there a possibility to fix that? shape.setAsBox(0.1f, 0.1f, new Vector2(0, 0), 0); bDef = new BodyDef(); bDef.type = BodyDef.BodyType.DynamicBody; bDef.position.set(0, 0); fDef.shape = shape; fDef.density = 0.001f; fDef.friction = 0.5f; fDef.restitution = 0.0f;

Libgdx and Box2DLights - too bright + colors grayed out

…衆ロ難τιáo~ 提交于 2020-01-05 03:05:35
问题 I'm writing a game with LibGDX and Box2DLights for lighting. The first problem is when my lights overlap each other. I have directional light on sun and point light on character. When they overlap output color is way too bright. I tried changing colors of lights but lowering these makes lights useless when there's only one light(too dark). My second problem is the colors are a bit grayed out(see on screen). Image showing my problems - first screen is too bright, second is with only one light

Couldn't load shared library box2d for libgdx

邮差的信 提交于 2020-01-02 06:39:10
问题 I have a libGDX project that is built using maven. It's run fine in the past, but recently, it's stopped working, due to libGDX moving box2d to being an extension. I added the extension as a dependency to the core of my project like I would any other dependency: <dependency> <groupId>com.badlogicgames.gdx</groupId> <artifactId>gdx-box2d</artifactId> <version>${gdx.version}</version> <scope>compile</scope> </dependency> however, when I try to run the project for desktop (or anything else,

How to make two bodies stick after a collision?

倾然丶 夕夏残阳落幕 提交于 2020-01-02 05:40:14
问题 I am really stuck on this I can successfully detect a collision but I can't make the two bodies involved in the collision to stick. Here is my ContactListener world.setContactListener(listener); listener = new ContactListener() { @Override public void preSolve(Contact contact, Manifold oldManifold) { } @Override public void postSolve(Contact contact, ContactImpulse impulse) { } //called when two fixtures cease to touch @Override public void endContact(Contact contact) { Fixture fixtureA =

Distinguish between collision surface orientations in box2d

孤街浪徒 提交于 2020-01-01 19:16:25
问题 I've been working on an iOS project, using Cocos2D 1.0 and Box2D, and I've run into a bit of a problem. What I need to be able to do is determine the orientation of a surface my player has hit. For example, if we have a rectangular platform, and the player collides with it, I need to know whether the player has hit the left, right, top, or bottom face of it. ALL the objects in the game are square, and the ONLY one moving is the player. I'm currently using a b2ContactListener in Box2D (well,

Android, libgdx and box2d basics [closed]

痴心易碎 提交于 2020-01-01 08:38:30
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I wrote couple of simple board games since i started on android learning, Please let me know is there any tutorial or links, where i can start with physics library with libgdx, looking for something like basics