libgdx-android: Intercepting back key and confirm exit

Using libgdx, how can I intercept the android BACK key in order to do some preprocessing (e.g. asking for confirmation from user), before actually performing the command to exit the game? Answer 1. Enable catching of Back Key. In the class that implements ApplicationListener @Override public void create() { … Gdx.input.setCatchBackKey(true); … } 2. Handle … Read more

Using the same font with different sizes in libgdx

I am using BitmapFonts, LabelStyles and Labels for my texts. I want to resize some labels, so I use this: fontType.scale(-.6f); LabelStyle style = new LabelStyle(fontType, Color.WHITE); titleLabel = new Label(“Points”, style); titleLabel.setColor(Color.RED); titleLabel.x = 260; titleLabel.y = 310; But when I want to resize another label, all the labels containing that font resize (I … Read more

android studio cannot resolve import org.json.JSONObject

I used libgdx to build my project and I am having issues using the JSONObject class. When I add import org.json.JSONObject, it says it cannot resolve. How do I add that library to my project? Here is what I have tried without success: I downloaded the json-simple-1.1.jar and put it in core/build/libs folder. Could not … Read more

Particle System libGDX [closed]

It’s difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 9 years ago. Can anyone give me a good example of … Read more

Error while importing projects

While importing projects into eclipse i have this error: Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory. Could not execute build using Gradle distribution ‘http://services.gradle.org/distributions/gradle-1.11-all.zip‘. As I have checked i need to set JAVA_HOME (i … Read more

Getting a directory file and the ClassLoader for a libGDX Android game

I have a libGDX game project for Android, and I want to execute a Groovy script in it. To do so, I am examining this example code: https://github.com/melix/grooidshell-example They managed to execute Groovy embed in Java on Android. Particularly GrooidShell.java (https://github.com/melix/grooidshell-example/blob/master/GroovyDroid/src/main/java/me/champeau/groovydroid/GrooidShell.java) I have managed to implement most of the code in the Android launcher of … Read more