Tag Info

Hot answers tagged

4

The problem you are facing is conversion between two different coordinates systems: the graphical one and the input one. Graphics coordinates Like you said, libGDX uses a 1 to 1 ratio between space coordinates and pixels, and starts in the bottom left corner. But it can be anything, really. That is just the default behavior of libGDX. You could change the ...


2

The skewing is because of how the viewport is setup, try changing it to something like this; @Override public void create() { ... bodyDef.position.set(0, 0); // Let this be at origin for now, it's easier to debug ... camera = new OrthographicCamera(200, 200 * ((float)Gdx.graphics.getHeight()/(float)Gdx.graphics.getWidth()); ...


2

One thing you could try is to draw the border as a line with a thickness first, then draw the inner part of the circle as a filled shape; shapeRenderer.begin(ShapeType.Line) Gdx.gl10.glLineWidht(borderWidth); shapeRenderer.setColor(borderColor); shapeRenderer.circle(x, y, radius + borderWidth); shapeRenderer.end(); shapeRenderer.begin(ShapeType.Filled) ...


2

In your DesktopLauncher it's not enough to just new up a LwjglApplicationConfiguration, you have to pass that along with your Game instance to the constructor of a LwjglApplication. Try changing your main method to this; public class DesktopLauncher { public static void main (String[] arg) { LwjglApplicationConfiguration config = new ...


1

If you are creating a 2D game with tiles you can easily implement your own culling which is a lot cheaper since you only itterate over exactly what you need within your tile array. Things you should know: Camera location Viewport width/height Tile width/height Now we can calculate how many tiles should be drawn. Total horizontal tiles on screen = ...


1

I don't think this is possible in your case. A repeating texture at the hardware level needs to span the entire texture, at least on the axis it is repeating. You can still repeat the sprite if you write your own routine. You would just call draw() multiple times. If you decide to load your repeating sprite as a separate texture so you can render it in one ...


1

What's Happening This is completely accurate physical behaviour, which can be explained using a free-body diagram and a little high school physics1: The mass of the block is m and g is the gravitational constant. Fa is the applied force. To understand why the block is not moving, we can write out the force balances in the x and y directions. x-Momentum ...


1

For path finding, A* (pronounced a star) ought to fit your situation real nice (for people who don't know what binding of Isaac is, it's basically the original legend of Zelda). For avoidance, I can't think of any named algorithms, but I think it will basically be pretty simple to code up some heuristics (rules) to where if an enemy is in the path of a ...


1

You need to specify the width and height when you draw the texture. batch.draw(texture, x, y, width, height); In your case you want to set the width and height to one since one wall tile is one world unit big. Because you don't specify a width and height the batch uses the width and height of the texture. That is why it covers 16 world units instead of ...


1

Adding to what Erez said, you can make any game without using a Viewport and just scaling your textures to a fraction of the screen size, but most of the time using a Viewport is a better option because it scales everything for you. Although you can use any measurement for the game width and height, I like to choose a target resolution for my game ...


1

What I ended up doing was having one Viewport that was an ExtendsViewport for just the joysticks. Then I added the pause button to the screen without using a table and manually set its size to a fraction of the physical screen resolution. This isn't a great solution because it required another Stage that didn't use a Viewport and since I had another Stage ...


1

I think problem is that you are using the size variable instead of the current count of the items that the array contains, in your for-loop. Example for-loop you should use: for(int i = 0 ; i < count ; i++) playerUnits.get(i).doSomething();. When you create an array, its default size is 16, even though it contains 0 items. As seen from the Array source ...


1

I had the solution for awhile, but I forgot to post. Here's the method to move a list of enemies towards the player. public void moveAlien() { for (Aliens a : aliens) { //List of Aliens (Enemy) Sprite s = a.getSprite(); //Get current enemy's sprite float targetX = spacemarine.getX(); //Player's X float targetY = spacemarine.getY(); //Player's Y ...


1

It is absolutly possible. Here's a simple class that, when called, will save a screenshot of the main graphical context: public class ScreenshotFactory { private static int counter = 1; public static void saveScreenshot(){ try{ FileHandle fh; do{ fh = new FileHandle("screenshot" + counter++ + ".png"); ...


1

Try this: package com.mycompany.mygame; import com.badlogic.gdx.*; import com.badlogic.gdx.graphics.*; import com.badlogic.gdx.graphics.g2d.*; import com.badlogic.gdx.math.*; public class MyGdxGame implements ApplicationListener { public float x; public float y; public float w = 50; public float h = 50; Texture texture; ...


1

Libgdx does not handle this itself, you need to take care about collision detection + collision response yourself. One possible solution would be Box2D, a 2D physic engine. It takes care about forces, mass, friction and other physical things. It also detects and handles collisions for you. It is also possible to let Box2D just detect the collision and notify ...


1

I am not 100% sure that this will solve your problem but it seems that you forgot to register the PositionMessage class. Be sure to register it in the same order on the client and the server and also, do not register the server and client classes.



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