Tag Info

New answers tagged

0

It's totally possible for multiple collisions to occur in your situation. What you can do is to check for the first time that happens, and then destroy your player only once. You can then disable collision detection for the player after that to prevent the 2nd, 3rd or more collisions from occurring anymore. You can also check to see if the player is ...


0

Currently developing a mobile game myself, using Box2D, I have no libgdx experience but for touch input on Android you can acquire a tap, a persistent touch, and a release! public void gameControls(final RelativeLayout gameBackground) { // Touch input. // Set up the touch listener for touch input on the screen. // Use the ...


0

Well for one this is in the touchUp method, which is called once when the screen is no longer being touched. A good way to do it would be to create a boolean "touchDown" that is accessible to the whole class and turn it to true in the touchDown method, and false in the touchUp method. Then you would apply the force to your jet ski while touchDown is true.


2

I've never tried to get this to work myself, but it seems like you would just need to increase the upward force applied to the jet ski's body as a function of the depth of the jet ski below the "surface" of the water object. The easiest way to get the distance below the surface might be to make a constant variable that describes the height of the water's ...


0

Allright I found the solutions. My phone was only capable of processing pictures with a size up to 4096*4096px and my Sprite was over 5000px...


0

This was apparently a known issue in the Box2D plugin. As much as I hate suggesting buying a library like this, they claim to have fixed this bug in the currently distributed version. If you're dead set on Phaser and this Box2D plugin, I would consider buying it but my honest advice would be to stay away from such libraries.


2

Yep, sounds right. A body abstractly represents a physical entity. A fixture defines its shape, physical properties and which other fixtures it collides with. Technical details in the Box2D manual, Chapter 7: Fixtures. Some reasons they are separate: This separates concerns by allowing the same fixtures to be used for all types of bodies (dynamic, ...


1

I had this class in previous project public class ExtendedCamera extends OrthographicCamera { public Player player; public ExtendedCamera(Player player) { super(Constants.WORLD_WIDTH, Constants.WORLD_HEIGHT); this.player = player; } public void followPlayer() { if (player.body.getPosition().x - position.x > ...


2

When centering the camera using lookAt you need to clamp the y value to be the max of the body's y and the y of the ground plus half the viewport height (possibly adjusting for the height of the ground). Something like this might make sense; float x = body.getWorldCenter().x; float y = Math.max(body.getWorldCenter().y, ground.getWorldCenter().y + ...


7

Ok, that's awkward. My last edit revealed the answer to my problem (that I've been struggling with all day): QGraphicsView casts the camera x/y position to integers... This is the solution: void SceneView::centerOn(const QPointF &pos) { if (mScene) { mScene->setX(int(-(pos.x() - width() / 2))); mScene->setY(int(-(pos.y() - ...


2

Emanuele Feronato did a tutorial on this some time ago, you can use it as a base: http://www.emanueleferonato.com/2012/03/05/breaking-objects-with-box2d-the-realistic-way/ To sum it up: Listen to collisions between your breakable body and the bodies that can break it; When collision happens, get the velocity of the body that can break the other and ...


2

I spent a good while looking how to implement Box2D in Android studio, so for anyone else in the same boat, or just looking to implement Box2D - here goes. For implementing Box2D into your java code/framework, Box2D is tuned to work with numbers between 0.1 and 10 (it works in meters), quoting from the Box2D manual: http://box2d.org/manual.pdf Box2D ...


2

It should work if you change these parts in show(): viewport = new ScalingViewport(Scaling.fillY, GAMESCREEN_WIDTH, GAMESCREEN_HEIGHT, camera = new OrthographicCamera()); and add a resize method: @Override public void resize(int width, int height) { int SCREEN_WIDTH = width; int SCREEN_HEIGHT = height; viewport.setWorldSize(GAMESCREEN_WIDTH, ...


1

Sounds like a simple rigidbody setting. Change from interpolate to extrapolate, or vice versa. http://docs.unity3d.com/ScriptReference/Rigidbody2D-interpolation.html


1

This will occur in Unity, if a GameObject is too small. The colliders will end up being either too far or overlapping, as the physics get unstable if the GameObjects are too small. Try making the gameobjects much larger (change the pixel per unit size), and you will see that it will more than likely fix your problem.


1

You could try changing the collision detection to Continuous or Continuous Dynamic. See the Unity Manual: Rigidbody for further info.


1

I was playing around a little and rereading the manual again. It noted that the size of the actual box is 2x the given size. Half-widths. So I continued to play around inside my graphics system and continued to see where the box was colliding and not and ended up with: Negate the (untouched) size from the position. Double the size of the boxes. glm::vec2 ...


1

This is a quite known issue in box2d, the problem is that you are rendering a rectangle per Tile and in the joint of those there is a ghost vertex, you can read extensive explanation here: http://www.iforce2d.net/b2dtut/ghost-vertices As for a solution to that i solved it by creating an object layer in my tiled map and created a Polyline object that defines ...


0

Your best bet is to extend the Image class and add a touch listener. Add this code into your Image subclass: private void addTouchListener() { this.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { YourClassName.this.wasTouched(); } }); }



Top 50 recent answers are included