Tag Info

Hot answers tagged

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, ...


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

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 + ...


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 ...


1

This is the logic: Create ImageButtons or TextButtons first Add these to a Table Create a ScrollPane with the Table Set ScrollPane position and size. You can disable scrolling in a direction using scrollPane.setScrollingDisabled() Add ScrollPane to the Stage


1

Try turning on the grid in Tiled (Ctrl+G) and adjusting your "Tile Side Length" in the Map Properties so that the grid matches correctly with your tiles. It may fix the libgdx rendering issue, and would improve the mouse picking in Tiled a little. I know setting up a hexagonal map (and even an isometric map) is somewhat confusing at the moment. It's ...


1

Possible? Obviously. http://www.android.com/tv/ showcases a few games that are available. I assume that they are using the same channels that they would use to make a game for a phone or a tablet, based on the pictures and a little familiarity with the SDK. Although I don't use libGDX that much, I assume that because it rides on the Android SDK, it ...


1

Assuming you're using a Vector2 for your motion (or an x-speed and a y-speed variable), you just need to do a little trigonometry. To find the angle of travel, you take the arctangent of the y-speed divided by the x-speed. Let's call your motion vector "velocity." You can derive the angle by taking atan(velocity.y/velocity.x).


1

After much frustration, I found out that I had made a folder the same name with the text file by mistake!! After deleting the folder all works fine, thank you for replying!


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 > ...


1

In order to make the title appear with the image you need to use the location of the image plus an offset. The reason (PPlane.WIDTH / 2) - (title.getWidth() / 2) works to center the image is because you're finding the midpoint of the PPlane and then subtracting an offset equal to half of the title's width which has the effect of centering the image ...


1

As described here (last chapter), please check the value of the field renderCalls in your SpriteBatch (you have only one unique SpriteBatch instance right ?), this should tell you the real number of draw calls that the batch has made. If you have more renderCalls than what you would expect then maxSpritesInBatch value is too low or your sprites have ...


1

Use of delta is to smooth your animation or as you said "making it independent of frames". So may be separating animation with the position calculation can solve your problem. For example, First calculate your next position in separate method then show your animation, by adding delta to initial position to final position, without loosing the initial ...


1

I think if it is invisible and if it is not affecting gameplay it is acceptable. But if you want a solution you can set a flag when starting collision detection, when the flag is true don't move your objects and store how amount they should move. If a collision happens extract how much it should go back from stored value and apply the stored value then set ...


1

What you want to do is determine how much the two AABBs overlap and then move them apart based on that amount. You already have an overlaps method. If you tweak that to return the amount that the AABBs overlap (on each axis) then you can just move your player back by that amount. That assumes that what you're colliding with doesn't need to be pushed back ...


1

Instead of casting rays in 360 degree fashion, cast rays to the corners of the tiles in range of the lightsource. Sort the angles from the light source to the tile corners and do a 'sweep'. You can optimize the algorithm to look for the nearest tiles first and ignore angles for culled tiles: A--B E--F o |T1| |T2| C--D G--H Angles would be ...


1

I used this solution to make a water distortion effect. You could use the sin waves vertically instead of horizontally to possibly achieve your effect. I draw what might get distorted onto a FrameBuffer. I make regions of the buffer texture that will be redrawn with a distortion shader applied. GdxGame.java void create(){ scaleX = ...



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