As of May 31, 2023, we have updated our Code of Conduct.

Hot answers tagged

77 votes

How can I give the illusion of height to a ball in 2D?

Shadow and texture. Texturize the ball to show it rotating. This helps give the illusion of rotation of a sphere, which is more than 2 dimensions. A shadow can trick your brain into believing all ...
House's user avatar
  • 73k
42 votes
Accepted

How to animate abstract 2d top down water texture?

A common way this is done is using an indirect texture lookup in the shader to distort the display texture: Here I'm using a texture with some low-frequency colour noise (tiling smooth blobs of ...
DMGregory's user avatar
  • 126k
26 votes
Accepted

How do I move the camera in full pixel intervals?

Your problem isn't moving the camera in full-pixel increments. It's that your texel-to-pixel ratio is slightly non-integer. I'll borrow some examples from this similar question I answered on ...
DMGregory's user avatar
  • 126k
16 votes
Accepted

Java and Steam JVM deployment

As someone who has recently released a libGDX game on Steam, unlike .NET and DirectX, Steam does not provide an option with your application to automatically check and download the version you need of ...
nhydock's user avatar
  • 339
15 votes
Accepted

BitmapFont - where is getBounds method in new 1.6 libGDX

There was a post explaining the changes, but is not easy to find. The link was on the 1.5.6 release changelog: http://www.badlogicgames.com/wordpress/?p=3666 And the link about changes in fonts was: ...
someoneigna's user avatar
15 votes
Accepted

How can I implement smooth tile-based lighting?

A simple way to achieve smooth lighting in a tile based game, is to draw a "lightmap" to a render target, and then drawing this render target over top your scene while alpha blending it. Your light ...
jgallant's user avatar
  • 8,314
13 votes
Accepted

Is it reasonable to use FreeType

If you use a font rendering engine like FreeType, then the most common mistake is to re-render strings every frame. This is pointless, because when you render a string, it will usually be on the ...
Philipp's user avatar
  • 117k
10 votes
Accepted

LibGDX viewport touch coordinates transformation

I hope I am understanding your question correctly -- if not let me know. I believe the following is where you are unprojecting the coordinates: ...
CodeNMore's user avatar
  • 441
10 votes

How can I make expanding bullet pattern shapes?

The easiest way to do this would be to first design the shape then calculate the movement of the particles. In this answer I will be constructing a square, but this applies to any shape. Start by ...
Charanor's user avatar
  • 7,750
9 votes

Implementing Spine animations in Libgdx

Here is an official Spine 2D example where they load Spineboy into a game. https://github.com/EsotericSoftware/spine-superspineboy The following 4 lines are used to read a texture atlas and skeleton ...
Fooble's user avatar
  • 310
9 votes

LibGDX Game vs ApplicationAdapter

As @user3068350 said, both Game and ApplicationAdapter implement ApplicationListener. It's useful to extend Game if you plan on using the Screen interface in your game, however some developers may ...
driima's user avatar
  • 995
9 votes
Accepted

Main game objects as static

It won't hurt performance. It might in fact be (very, very negligible) faster because you save the overhead of passing these objects to the game objects. The reason static classes are often frowned ...
Philipp's user avatar
  • 117k
9 votes
Accepted

LibGDX simple button with image

A drawable has information about its size and how to draw itself. It's used to determine size and position by ui components. Since you are using a texture, you can use a TextureRegionDrawable. ...
user3068350's user avatar
8 votes

How do I render a rounded rectangle in libgdx?

In case it's useful for anyone, here's my extension of LibGDX's ShapeRenderer to draw rectangles with rounded corners, using Josh Petrie's approach of drawing five rectangles and four arches. I ...
J. Mac's user avatar
  • 81
8 votes
Accepted

Why does flipping 1 texture region cause an identical texture region to also be flipped? (libGDX)

TextureAtlas#findRegion(String) returns a region with a name that matches the name specified. It does not copy the region, therefore any changes you make to the ...
driima's user avatar
  • 995
8 votes

How do I delete all saved preferences in my libgdx project?

To delete preferences data— Manually On desktop, shared preferences data is in User/.prefs. Simply delete the files in it. On Android, do App Info → Clear data. ...
Netero's user avatar
  • 191
8 votes
Accepted

Shaperenderer circle line width

Set the OpenGL line width. ...
bornander's user avatar
  • 4,401
8 votes
Accepted

How do I save which NPCs the player has talked to?

I am not familiar to the particular engine you are working with, but in most languages or cases you can use a 1xn matrix (i.e. a vector) where n is the total number of NPCs, that stores the 1-or-0 ...
MAnd's user avatar
  • 4,907
8 votes
Accepted

Profiling LibGDX game with GLProfiler

You seem to lack some insight on your issue. A couple of things to consider: Is your true maximum frame rate on your PC really 60 or is it more? NVida drivers limit the frame rate to the maximum ...
Vaillancourt's user avatar
  • 16.1k
8 votes
Accepted

What is the difference between expand(), grow() and fill() in libGDX?

Expand: expands the cell that the actor is currently placed in to occupy the largest possible area without changing other cells size. For example if the cell is <...
Charanor's user avatar
  • 7,750
8 votes

Why do separate loops run faster than one loop that does multiple things?

This is not an unexpected result actually. It's a little like how a person's efficiency plummets when they try to multi-task, compared to when they can focus on doing one specific job. Modern CPUs in ...
DMGregory's user avatar
  • 126k
7 votes

Smooth Shapes in libgdx using ShapeRenderer

You could try turning on multi-sampling when applying the application configuration. The Multi Sampling Anti Aliasing is controlled with the numSamples property for ...
bornander's user avatar
  • 4,401
7 votes
Accepted

How do I check for collision between an ellipse and a rectangle?

I'm going to tell you how to do it with a computationally cheap way in terms of CPU usage. First, let's say that the calculation of seking if a point is "inside the ellipse or not" is not ...
Xavi Montero's user avatar
  • 1,063
7 votes

LibGDX simple button with image

Something like this should work; ...
Jax's user avatar
  • 420
7 votes
Accepted

Difference Between LibGDX and LWGJL

LibGDX is based on LWGL and its advantage are that a lot of the base stuff is already written and you don't need to write it. Some people prefer to write it themselves though. LibGDX is generally used ...
ProRed's user avatar
  • 330
7 votes
Accepted

Is it possible to use animated .gif images in lbgdx?

There is a GifDecoder class that turn a .gif file into a libGDX Animation. With it, you can render animated .gifs like this; <...
bornander's user avatar
  • 4,401
7 votes
Accepted

LibGDX - My sprite glitches when it moves

It happens because you update the camera's position out of sync with the player's position. In public void render(float delta) ...
bornander's user avatar
  • 4,401
6 votes

In LibGDX, how might I make an object orbit around a position?

If you wish for an object to orbit around a specified point in two dimensional space, you want to use some trigonometric functions. Here is an example method to calculate an objects position in an ...
Aidan Lovelace's user avatar
6 votes

LibGDX : Textfield input type

I found out a solution to your other problem. To allow the typing of a dot you should create your own implementation of TextFieldFilter like this. ...
Zigur's user avatar
  • 83

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