box2d

Box2D/AndEngine - ContactListener for multiple object classes

拥有回忆 提交于 2019-12-25 01:16:05
问题 I'm developing a little Android game in Java, using AndEngine for graphics and Box2D for physics - specifically, collision handling. I have some different types of objects with constructors in classes, like so: MainActivity.java Enemy.java Npc.java Door.java I have a static PhysicsWorld in the main class, and I was setting up a ContactListener from the Enemy class, to define what happens when one of the enemies hits something. However, I tried to set up another ContactListener for the Door

Farseer - Particles doesn´t move/bounce accord to borders

↘锁芯ラ 提交于 2019-12-24 21:20:09
问题 I made my borders with this: class Maze { private Body _agentBody; private Sprite _box; private GameplayScreen _screen; private float _offset; public Maze(World world, GameplayScreen screen, Vector2 position) { _agentBody = BodyFactory.CreateBody(world, position); _agentBody.BodyType = BodyType.Dynamic; _agentBody.IsStatic = true; _agentBody.Restitution = 0.2f; _agentBody.Friction = 0.2f; _offset = ConvertUnits.ToDisplayUnits(1f); // spodek _agentBody.CreateFixture(new PolygonShape

why ApplyLinearImpulse is not same every time on same body with same values using box2d in cocos2d - x?

橙三吉。 提交于 2019-12-24 13:42:31
问题 I want to know the exact functioning of Impulse Function in box2d. right now i am trying to apply Impulse on same kind of bodies with same kind of value of force . For Ex. b2Vec2 force = b2Vec2(20,50); MyBody->ApplyLinearImpulse(force, MyBody->GetPosition(), true); on above example i am applying force with static values on my dynamic bodies , now every Mybody not behaving same kind of force. why is it so ?!! According to my understanding , it should behave same every time. or am i wrong ?!..

Box2D debug draw in a specific layer

不想你离开。 提交于 2019-12-24 12:43:11
问题 This article tell how to wrap Box2D debug draw in a layer. But I do not understand why it is being drawn in the specific layer. As far as I don't know OpenGL, I don't understand where it is being drawn at all. But my problem is that I want to draw in a specific layer, so that I could put that layer on top of all layers and make Box2D shapes always visible. Today I have found the solution how to do debug draw Box2D shapes in C++ but I cannot draw in a specific layer. Could you help me

Box2d Bodies that are really close together, are getting “stuck”

血红的双手。 提交于 2019-12-24 10:40:49
问题 Im using a tiled tmx map, and I created a class that adds bodies to each tile within a certain layer. This has been working great so far except for when a character or an enemy moves around on the screen, its body gets stuck on an edge between two tiles. This seems to happen "sometimes" and in certain spots. Jumping makes u unstuck but its annoying when it happens, and i tried increasing the position iterations, but the problem keeps reoccurring. Heres what my game looks like: http://i.stack

box2d triangulation of static body

浪子不回头ぞ 提交于 2019-12-24 07:29:12
问题 I have posted on this before, but to no avail. Sorry for slightly repeating myself but I have tried to figure this out and I haven't been able to. I am probably not understanding something in box2d. I therefore wrote a very simplified example to highlight the issue. In my code I simply create a rectangle. I triangulate it and then I add it to a box2d world. If I define the object as a dynamic object (density > 0) it is reacting to the walls and objects within the scene see images here. If I

Collision Detection in Box2D

喜你入骨 提交于 2019-12-24 01:25:34
问题 So I'm using Box2D for collision detection in a game. I have a tilemap that contains information on the terrain: for now it's just a char[][] that has either road or grass. Now, at the start of each level I wanted to create rectangles to describe the different terrains, but I wanted these rectangles to be optimized and apparently that takes quite an algorithm. My first approach was to create an individual terrain for EVERY tile in the map at the start of the level. The FPS was reduced to 5.

Emscripten Bindings: How to create an accessible C/C++ array from Javascript?

…衆ロ難τιáo~ 提交于 2019-12-24 00:34:47
问题 I am using box2d and attempting to create a chain shape. In order to create a chain shape or polygon shape I must pass an array of vectors in order to specify the geometry. I do not see any documentation to help me accomplish this, and the notes about bindings here don't go into any detail about arrays. How can I construct an array? 回答1: I have solved this problem by using these (as yet undocumented) emscripten features. Note that I am accessing the functions and values (like ALLOC_STACK and

Is there a functional difference between “2.00” and “2.00f”?

五迷三道 提交于 2019-12-23 20:15:37
问题 I ask because I am using the Box2D library, which calls for mostly float arguments. Although I see a lot of example code that uses the 0.00f format, I am not quite sure if there is an actual difference between that and plain old 0.00 . Will I be hurting myself later on by not appending the additional f ? Is it a speed thing? Is there some sort of connotation that would need the f addend when others wouldn't? tl;dr? Why should I be using 0.00f instead of 0.00? 回答1: The f suffix makes it a

Whats the best way to do character animations with Box2D?

北战南征 提交于 2019-12-23 17:41:57
问题 I am developing a 2D, underwater, action-RPG for Android, using Box2D as the physics engine, mainly for collision detection, collision response and movement of in-game characters within an environment comprised of walls, rocks, and other creatures. I have tried two different approaches for implementing character animations using Box2D, and have found issues with both. As I'm new to Box2D and physics engines, I would appreciate a recommendation on how these things should best be done. An