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 ...
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 ...
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 ...
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 ...
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:
...
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 ...
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 ...
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:
...
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 ...
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 ...
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 ...
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 ...
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.
...
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 ...
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 ...
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.
...
8
votes
Accepted
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 ...
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 ...
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 <...
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 ...
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 ...
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 ...
7
votes
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 ...
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;
<...
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) ...
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 ...
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.
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
libgdx × 2280java × 959
android × 437
box2d × 273
collision-detection × 105
2d × 98
opengl × 94
sprites × 90
textures × 81
scene2d × 80
camera × 69
rendering × 66
animation × 56
physics × 55
tilemap × 55
tiled × 43
input × 41
mathematics × 39
rotation × 39
movement × 36
fonts × 36
shaders × 35
tiles × 34
graphics × 33
android-studio × 33