FAQ Database Discussion Community


Player Movement Direction Logic

java,libgdx,logic,game-engine
Consider points A and B as walls and point O as player inside walls. So they look like A O B. I want player to move left when he touches rightPoint B. And move right when he touches leftPoint A. The screen is being rendered and player position is either...

LibGDX, intermittent lagging whilst moving an object

android,libgdx
I create little sprites of sheeps on the top of my screen, then they should go down and after crossing bottom line they disappear. Problem is that when they are going across the screen it is very noticable that sometimes they lag. For milliseconds but its possible to see it....

Libgdx Texture Size Android

java,android,libgdx
I'm having problem with scaling images ,every device has different screen resolution and i can't figure out how scale them down in the Libgdx Platform, for example today i've made a small game for android and the problem that i am facing is.. offcurse we can scale them down ,but...

algorithm for ai to chase player in straight line?

java,algorithm,path,libgdx
I am making a game in libgdx(java) where squares chase the main player. I can't figure out how to make the squares move in a straight line directly to the player at a constant speed. this means i want the squares to travel the same distance every second. I make...

BitmapFont class does not have getBound(String) method

java,android,libgdx
Previously I used getBound method for BitmapFont class in libgdx, but now, I am unable to use it. I cannot find the changes in latest version. Any help is appreciated. Thank you...

libgdx: “java.exe finished with non-zero exit value 1” while building to HTML

java,html,libgdx
I have been trying to debug my libgdx code on HTML, the building process happens perfectly when I use the default libgdx new project code, but if I change it to my code this happens: FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':html:superDev'....

Libgdx Trigonometry Wrong Angle

libgdx,trigonometry
I am building a top down shooter like Counter Strike 2D there is problem with velecity: public class Player extends Entity { private float moveSpeed; private float turnSpeed; private float maxSpeed; private float moveFriction; private float turnFriction; private Texture tex; private Sprite sprite; private ArrayList<Bullet> bullets; public Player() { moveSpeed...

How to remove Sprite/Object from ArrayList? [duplicate]

java,arraylist,libgdx,sprite
This question is an exact duplicate of: Removing sprite when Touched 1 answer I created an ArrayList just for the sprites that needs to be removed, when the sprites are touched they are added to the ArrayList. //drawing the enemy that spawns and making them move public void draw(SpriteBatch...

libgdx on desktop - Determine if mouse outside window

java,libgdx
I need to be able to check if the mouse is outside the window of my libgdx app running on a windows desktop. Gdx.input.getX() and Gdx.input.getY() are constrained to my app window on Windows (but not on Mac). I tried Gdx.input.setCatched(true) which does make it unconstrained, but it also binds...

Libgdx: File not found error 'Internal' when opening external file

android,libgdx
Here is a good one for you. I'm trying to open a file using external. FileHandle dirHandel = Gdx.files.external("MyApps/skanectModel.g3db"); boolean isDir = Gdx.files.external("MyApps/skanectModel.g3db").exists(); I know the file is there, and the bool tells me that in fact it is there. The main problem is that I get this error. Caused...

How to import the LibGdx sample project

java,import,libgdx
I need to import the project as mentioned in this link. I am not using git, hence I have downloaded the project zip folder and extracted. Could you please let me know how to import this LibGdx sample project ? ...

how to add a library to the dependencies gradle of LIBGDX project

java,eclipse,gradle,libgdx
All is in the question , I've tried all the answers I found in SO and others sites but with no luck , this is what I've tried so far : adding compile fileTree(dir: 'lib', include: '*.jar') to my build.gradle adding compile files('lib/tween-engine-api-sources.jar') to build.gradle the library I want to...

Libgdx falling circles

java,libgdx,circle
I am working on a libgdx game and am having a certain problem. I am trying to constantly generate random coordinates (above the screen) and for each coordinate, draw a circle. Then add to their y-coordinates so they will have a falling effect. Once a circle is off the screen,...

Moving an object in elliptical Path

libgdx,tween
In my LigGdx based game, I wish to move my Sprite in an elliptical path to reach the destination. I do not find any support in Universal tween engine. Sample of route example is shown below. Questions : Is there is any methods in UniversalTween Engine to have a elliptical...

Set up wraparound effect in libGDX with Box2D

libgdx,box2d
i have been having trouble trying to set up wraparound in LibGDX using box2D, for example i want my player to appear at the left side of the screen after exiting the right side, but its not working here is my code: public void setWraparound(){ //if player goes out of...

For-loop gives only one value when iterating through an array of Vectors (libGDX)

java,arrays,for-loop,libgdx
I'm just a beginner, so here's probably some small mistake which I can recognize but yeah... I'm using libGDX library and here's code of my method: public Vector2[] initCollisionStart() { int i = 0; for (int row = 0; row < currentMapHeightTiles; row++) { for (int col = 0; col...

Pixelated texture filtering distorted

java,libgdx,filtering,isometric,texturepacker
I've created a isometric tile based game in Libgdx. The textures I'm using are 64x64 and packed using TexturePacker into a TextureAtlas. They are then drawn onto the screen. However, while moving around the pixelated edges of the 64x64 texture flicker and they are distorted, which can be seen in...

How do I push and pop the matrix stack in LibGDX

java,opengl,libgdx
I'm having a hard time finding the equivalent of the very basic OpenGL functionality glPushMatrix and glPopMatrix in LibGDX. I have rendered my scene and I would like to render an overlay on top of the scene but I would like to do it in screen coordinates so I want...

Libgdx - How to get a specific item from an array?

arrays,libgdx
I have a Player class which has int number; In main, I store them in Array. Array<Player> players; How can I get a player which has for example number=2?...

libGDX: Opening 3D scene from 2D screen

java,libgdx
Using libGDX I have created a few 2D screens, such as a splash screen and a main menu, and also created a 3D scene which I want to be able to load when clicking a button on the main menu. I know how to add a listener but I don't...

How to remove Sprite when collision is detected? Libgdx

java,libgdx,collision,rectangles
Every random time (between 1,2 and 3 seconds) a rectangle and a sprite is created,1 rectangle for each sprite that spawns. new enemy method is called at random time: public void newEnemy(){ Sprite enemy= Pools.obtain(Sprite.class); enemy.set(enemySpr); enemy.setPosition(200,150); enemies.add(enemy);} the same thing happens to rectangles: public void newRect(){ Rectangle rect=Pools.obtain(Rectangle.class); rect.set(enemyRect);...

Why is my pointer y coordinate reversed?

java,libgdx
When I click on the top left corner it gives me 0,0 but I want the opposite result. I want to have a 0,0 coordinate when I click on the bottom left corner. Basically when I go down the y coordinate is higher and when I go up the y...

How do I load multiple textures from the same file?

java,libgdx
How do I load multiple textures from the same file? I'm learning LibGDX and I don't know how this process is named. I have a file that contains all the textures I need. Is it possible to load textures by selecting regions on the same file?...

InputListener for the Actor

java,libgdx,scene2d
I have a problem that keyDown event is never fired in the Actor when I press any key. Though, the touchDown (for mouse clicks) works. Actor code: public class MapActor extends Actor { private TiledMap map; private OrthogonalTiledMapRenderer renderer; private int directions = 0; private OrthographicCamera camera; public MapActor(String pathToMap,...

Eclipse crashes with GC overhead limit exceded after linking google play services

java,android,eclipse,memory,libgdx
So I'm building a project using LibGdx and have had trouble for the past few days trying to fix this issue. I have followed many other posts about the same question but had no success. Essentially as soon as I link my android project with google-play-services-lib and try to debug,...

libgdx drawing arc curve

java,libgdx
The arc function of libgdx instead of drawing a arc draws a pie segment (ie. has 2 lines connecting to the arc's origin) shapeRenderer.begin(ShapeType.Line); shapeRenderer.arc(x, y, radius, 30, 120); shapeRenderer.end(); Is there a solution to this problem so that libgdx can draw an arc curve similar to the html5 canvas...

Object Speed in libgdx

java,performance,libgdx,bullet
I'm learning libgdx development and I'm having trouble while editing demos: I'm editing a oficial flappy bird demo, I removed the rocks and I added some bullets (From right to left) here is my code: public class FGame implements Screen { // General constants private static final float PLANE_JUMP_IMPULSE =...

(Libgdx 1.6.1) BitmapFontCache.draw crashing due to index out of bounds

java,libgdx,lwjgl,glyph
I just recently updated my Libgdx project from 1.4.x to 1.6.1. I use BitmapFontCache for my dialogue in my game, drawing a string character by character using BitmapFontCache.draw(start, end). This was working fine in 1.4.x but after making the necessary changes to get 1.6.1 to build, it seems to cause...

LibGDX - Rendering an Angry Birds style animated score counter

libgdx,level,scoring
My game has an end of level screen, on which I wish to display an animated player score. If you have seen the one in Angry birds and many other games, the score text starts at "000000" and increments rapidly until it reachs the actual score the player achieved. I...

How can I use the Accelerometer for detecting jump in LibGDX?

android,libgdx,accelerometer
I make an app for android. I'll use the accelerometer for detecting jump.Does someone know how that works? And which value will change and with how much?

Add a row to the top of a Table (LibGdx)

java,libgdx
How can I add a line at the top of a Table in LibGdx ? tableName.add(rowElement); In this way, it adds a line to the end of the table (bottom). I need to do the opposite. tableName.add(rowElement).align(Align.top); // didn't work Code: Table mainTable = new Table(); mainTable.center().top(); Table message =...

libGDX Java (Desktop): SelectBox throwing exception

java,libgdx,scene2d
I have an issue creating a select box for my application. I couldn't find a solution anywhere else. My code: public class OptionsMenu implements Screen{ private Stage stage = new Stage(); private Skin skin = new Skin(Gdx.files.internal("jsonurlhere"), new TextureAtlas(Gdx.files.internal("atlasurlhere"))); private String[] viewmodes = new String[] {"Fullscreen", "Windowed"}; private SelectBox<String> viewmode;...

LibGDX could not parse tmx file: file not found

java,eclipse,libgdx
I'm attempting to show an isometric tiled map using LibGDX and Eclipse. However, when running the project i encounter this error(s): Exception in thread "LWJGL Application" com.badlogic.gdx.utils.SerializationException: Error parsing file: E:/Documenti/eclipseiso/desktop/map.tmx at com.badlogic.gdx.utils.XmlReader.parse(XmlReader.java:83) at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:78) at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:65) at com.mygdx.eclipseiso.screens.Play.show(Play.java:20)...

LibGDX SpriteBatch rendering error

java,libgdx,sprite,render,spritebatch
So earlier when I was testing my game everything went well, then I added some code. In my game I have states like PlayState or MenuState and now everything goes well, but when I try to switch the states in-game, the following error occurs: Exception in thread "LWJGL Application" java.lang.NullPointerException...

Java libGDX will not draw sprites when the camera coordinates do not match the window coordinates

java,libgdx
I am having a problem with the libGDX engine. I have a pair of variables to set the width and height of the screen, and another pair to set the width and height of the camera. However, whenever the camera is not the same size as the screen, the engine...

Getting console error [duplicate]

java,libgdx
This question already has an answer here: What is a Null Pointer Exception, and how do I fix it? 12 answers I'm using libgdx trying to make a game, but when I run this from the desktoplauncher, I get a error in the console: Exception in thread "LWJGL Application"...

Java - LibGDX - Problems with the process of rendering a Tiled map

java,android,libgdx,tiled,tmx
The problem I cannot seem to be able to get Tiled maps to render properly. I am using LibGDX as a library for loading the map (Release 1.6.0). Video demonstration I have created a video to show you the actual problem and make things easier by skipping the whole process...

Libgdx Actor undetected touch input

java,libgdx,touch,actor
I am looking for touch detection. The code showed below is what I did to set a circle in my app. I want detect touch on this circle and not around or on the entire texture. The strange thing is that touch isn't detected, in nowhere I can detect it...

LibGDX shaperenderer wrong color

colors,libgdx,shape-rendering
I am in trouble setting the color of my rect. The color of my rect is grey with 0.5f alpha or black with 0. How could I set my color? This is the code : Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); shapeRenderer.begin(ShapeRenderer.ShapeType.Filled); shapeRenderer.setColor(67 , 34 , 167, 0.5f); shapeRenderer.rect(0, 0, Width,...

How to use network frameworks (volley , okhttp , etc) in libgdx?

android,libgdx,android-volley,okhttp
I want to load some data from web using volley or okhttp in libgdx. How to use network frameworks like volley or okhttp in libgdx instead of libgdx networking class ?...

I have an Array of 2 objects, when I use a for loop, both of the object gets the change that only one of them should have

java,arrays,for-loop,libgdx,box2d
Basically I have this code : for(int i = 0; i < tnt.size; i++){ TNT t = tnt.get(i); if(cl.isVänster()){ t.getBody().setLinearVelocity(6,0); } if(cl.isHöger()){t.getBody().setLinearVelocity(-6,0); } if(t.getBody().getPosition().x > 1888/PPM){t.getBody().setLinearVelocity(-6,0); } if(t.getBody().getPosition().x < 31/PPM){t.getBody().setLinearVelocity(6,0);} } What happens is if I have 2 objects in this Array, when something happens to object #1 it gets...

libGDX TextureAtlas - providing master texture filename at runtime

libgdx
I would like to use identical .atlas file for multiple master texture files. This can be easily achieved by having multiple almost identical .atlas files (with only difference being the first line with the texture file name), but it's not a nicest solution. I was wondering if it's possible to...

Libgdx Viewport with stage not working [Fixed]

java,android,libgdx,viewport,scene2d
So 2 months ago i stumbled upon the problem that my game that i was working on did not scale with other devices. So i decided to implement viewports since people said that it was the best way and also an easy way. But its been around 2 months since...

move body to specific point in world coordinates at a constant speed

libgdx
I have a kinematic body with gravity 0 which I want to move from a specific point to a specific point in my world coordinates. I've tried to adjust the code from here to the one below. But the body stays still and doesn't move? @Override public void act(float delta)...

Using comparable to compare different variables

java,libgdx,comparison,comparator,comparable
I'm familiar with standard comparisons using the Comparable interface, although today I'm having some trouble when I want to compare several different variables. I basically want to implement a compareTo method that yields the result -1 only when the following if statement is true: if (o.maxX > minX && o.maxY...

Libgdx sliding screen transition

android,libgdx
I have a libgdx project with a Game as the base class and two Screens (my menu screen and my splash screen). I want, when the splash screen has finished, to slide the splash screen to the right and put the menu screen. I can just make an instant transfer...

Libgdx tweening issue

java,libgdx,sprite,scaling,tween
I am creating a game and trying to set up a splash screen. Whenever I render the sprite that i want to tween to by using the sprite.draw method which looks like this: @Override public void render(float delta) { Gdx.gl20.glClearColor(0.2F, 0.5F, 1F, 1F); Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT); tm.update(delta); cam.update(); sb.setProjectionMatrix(cam.combined); sb.begin(); Assets.splash_spr_bg.draw(sb); sb.end();...

How can I run a libGDX application on a non-GUI server environment?

java,linux,ubuntu,libgdx,server
I built a libGDX application that runs well on my PC desktop but when I try to run it on my Ubuntu server, it raises the following error: "LwjglApplication: Couldn't initialize audio, disabling audio java.lang.UnsatisfiedLinkError: /tmp/libgdxroot/31ce78a2/liblwjgl64.so: /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/../lib/amd64/libjawt.so: symbol awt_Unlock, version SUNWprivate_1.1 not defined in file libmawt.so with link time reference"....

how do you make a Rectangle change it's position or move?

java,libgdx,collision,movement,rectangles
I'm using rectangles for collision detection and a rectangle is created every 3 seconds, I wan't the rectangle to move upward just like my sprite but .translateY() method can't be used on rectangle. this is what I did to my sprites stored on ArrayList: for(Sprite sprite:mySprite){ sprite.translateY(deltaTime*movementSpeed); } and this...

Getting the variables for DesktopLauncher using Libgdx

java,nullpointerexception,get,libgdx
I am trying to create a 2d game and right now I need the games width. I tried to use Gdx.graphics.getWidth() but that gives me a nullpointer. After searching through the web I came upon this http://www.badlogicgames.com/forum/viewtopic.php?f=15&t=13984 That is the explanation but as you can see in my code I...

Using abstract screen in LibGDX

java,android,libgdx,abstract-class
I want to use an abstract screen for my LigGDX game. I have read many websites and many of them use abstract screen only to group the common codes (e.g. common methods) together. If this is the case, we can simply use a normal class to do the task. The...

How do i correctly rotate an image in LibGDX?

java,libgdx
I am trying to make a game like asteroids, i want the player to face and move upwards (North) but when the game starts,the player is faceing to the right side(east). here is my code: public Player(float x, float y,int width,int height) { this.width = width; this.height = height; this.x...

draw texture on triangle mesh

libgdx,mesh
I am trying to draw a texture on a triangle mesh. I get the mesh but not the picture on it. See on the picture below. As you can see that's a plain triangle but no texture in it. String vertexShader = "attribute vec4 a_position; \n" + "attribute vec4 a_color;\n"...

LibGDX - load and process texture asynchronously

java,android,opengl-es,libgdx
There are a few discussions about async loading textures using Assets in LibGDX. As far as I know LibGDX uses 2 methods (async & sync) to load data. In case if it's rely on using OpenGL functions, it uses main thread with GL context and does it synchronously, otherwise asynchronously....

Font size in textfield libgdx

java,libgdx
How can I change the size of textfield font in libgdx? UserNameTextField = new TextField("", GlobalSKin); UserNameTextField. ??? ...

How to use timer with libgdx?

java,libgdx
I'm trying to use the gdx Timer to increment a value repeatedly but when I use this value inside a Label it seems like nothing happens and the value is stuck at 0 , here is my code for the timer : @Override public void show() { stage = new...

Android LibGDX 'Cannot resolve symbol setRadius'

java,android,libgdx
I'm using Box2d, libGDX and have imported ...physics.box2d.CircleShape; what did I do wrong such that setRadius isn't acceptable. Thanks for your time. import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.BitmapFont; import...

LibGDX TextureRegion draw bug when using split method and scaling

libgdx,render,scaling
I get a graphical glitch whenever I try to split my tileset into a TextureRegion[][] and drawing them. It works fine when I am using the default aspect ratio but when the window has to stretch, it seems to be accessing a line of pixels from the next tile in...

Libgdx scaling background issue

java,libgdx,textures,sprite,scaling
So i am creating a game where i will draw a background but this background doesen't cover the whole screen, even when i lower the window size it doesen't cover the whole window. Here is the code for drawing the background: Gdx.gl20.glClearColor(0.2F, 0.6F, 1F, 1F); Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT); cam.update(); sb.setProjectionMatrix(cam.combined); sb.begin(); sb.draw(Assets.splash_spr_background,...

libgdx keyDown distinguishing a long and short press

libgdx
Is there a way to handle a keydown that is just one click versus a keydown that is a long press in libgdx? Does it have anything to do with a gesture detector? to clarify, my question is about keyboard events, not touch and mouse events

Using world coordinates

java,libgdx
I am currently using pixels as units for placing objects within my world, however this can get tedious because I only ever place objects every 16 pixels. For example, I would like to be able to place an object at position 2 and have the object rendered at the pixel...

How do I deploy my LibGDX game to my website?

java,html5,gwt,libgdx,game-engine
The furthest I've gotten is running it on the browser through the command line. I went into the appropriate directory and used the ./gradlew html:superDev command and then went to the URL localhost:8080 and was able to play my game. However, what i need to do is put this game...

How do I add ads to my android-libGDX project?

java,android,eclipse,libgdx,ads
So I made my android-libGDX project and have my app finished and everything, but now I wanna add some ads. (because you know it costs $25 to make an account and I'm just a poor student). I know how to add google Play services but I can't get any further....

FacebookSDK on Android - SharePhotoContent with Message body

libgdx,facebook-android-sdk,android-sdk-tools,facebook-sdk-4.0,facebook-sdk-3.0
I have a button in my game where I make a finish level screen capture , I then attach that picture to a Facebook SharePhotoContent dialog from the newest SDK. It all works as it's supposed but how do I also insert a custom message body so that I replace...

libGDX desktop application JAR generation

android-studio,libgdx
I have a libGDX project(which is also desktop compatible) and would like to export its desktop application to a JAR file, to run it like a standalone application. How can I do this with use of Android Studio?

Timer not resuming after game loosing focus

java,timer,libgdx
I have a recurring task. I schedule it in the standard way (Timer is the libgdx one: com.badlogic.gdx.utils.Timer): Timer.schedule(myTask, 2, 2); When the user wants to pause the game, I call: Timer.instance().stop(); to pause the execution of the task. When the user resumes the game I call: Timer.instance().start(); This works...

Display loadingwheel during method

android,android-asynctask,libgdx
I share an image to different social medias, but this process takes a few seconds and can make the user think nothing is happening. So I want to display a loading wheel sort of. I got the animation finished but I can´t work out how to implement it so that...

Libgdx: How to calculate sprite size when viewport is in used

libgdx,viewport
I have few questions regarding using libgdx viewport. I have initialised a viewport with this virtual screen size (800 x 480). I'm trying to display a sprite with (100 x 100) virtual size. Do I recalculate based on the screen size ratio to supply the size? Or I just apply...

“Tainted canvases may not be loaded” Cross domain issue with WebGL textures

google-chrome,gwt,libgdx,html5-canvas,webgl
I've learnt a lot in the last 48 hours about cross domain policies, but apparently not enough. Following on from this question. My HTML5 game supports Facebook login. I'm trying to download profile pictures of people's friends. In the HTML5 version of my game I get the following error in...

LibGDX - How to combine Clicked() method from two click listeners in LibGDX similar to Android?

java,android,onclick,libgdx,onclicklistener
I want to combine the following two buttons (button1 & button2) into one clicked() method which is similar to Android using v.getId(). In LibGDX: button1.addListener(new ClickListener(){ @Override public void clicked(InputEvent event, float x, float y){ button1.setText("It was the first button."); } }); button2.addListener(new ClickListener(){ @Override public void clicked(InputEvent event, float...

Libgdx render for a rectangle array different textures

java,android,opengl-es,libgdx
I am developing a game with libgdx and i got stuck at a point. So My SpriteBatch draws for all the Rectangles that are in an array with the same texture but I want that every single one has its own texture. MY Code looks like this public class GameScreen...

How to get a variable from another class without calling a constructor?

java,constructor,static,libgdx,box2d
So, in LibGDX I am using box2d and I have a class for contact listening. I need to get my player's body without making a class object, because it will call the constructor the second time. And a static variable is not an option. How should I do this? Here...

LibGDX multiple cameras

java,fonts,camera,libgdx,bitmap-fonts
So, I am working with LiBGDX and Box2D, using the PixelsPerMeter conversion, and I have a camera that follows the player around, but when I turn debug mode on I need to be able to draw a font with the fps on screen, so I always can see it in...

Does the game engine allow me to intergarte native android code

android,unity3d,libgdx,andengine
I am looking into using Game Engine for one of my apps. I have been android developer for a while but never used a game engine. I know the most famous engines out there are AndEngine, Libgdx and Unity Which engine would allow me to use the native android code...

eclipse import gradle project download take forever

java,eclipse,eclipse-plugin,libgdx
i tried to generate project with libgdx and then import it to eclipse but it take forever more than 5 hours on downloading dependencies , however it works fine from the command line but not eclipse or even netbeans (same problem) so what is the problem ? is there any...

Admob slows down my game - LIBGDX

android,libgdx,admob
I have my game perfectly optimized. Doesn't go bellow 61-60 FPS. When I finish the level or the user dies the pause/restart dialog appears (Scene2D). The problem is that I still have moving sprites in the background and it would make the game look not so good if I would...

TextButton doesn't update its label text

libgdx,scene2d
I have a TextButton inside a Stack and after I change its style and update its text I see no text in the Label. I even used the setText method in render(float delta) but no luck. I should mention that prior to calling the setText method the Stack also contained...

Sprite setTexture not woking

java,libgdx
I'm new to libgdx and I don't know yet how the Sprite class works, so I run into a bit of a problem with Sprite.setTexture() not woking(I need this for animations). Long story short(as an example): sprite = new Sprite (imgb); //work flawlessly sprite2 = new Sprite (); sprite2.setTexture (imgb);...

Launching Libgdx project to IPhonesimulator

ios,libgdx,robovm
Im trying to make sure my app works on IOS. And doing so by trying to launch it to a IPhonesimulator on my mac. doing: ./gradlew ios:launchIPhoneSimulator Makes my app start on the simulator, the standard splashscreen by libgdx appears and then it shuts down and nothing more happends. But...

My mesh is not rendering, but everything seems fine

opengl,libgdx
There is no log, no stack trace, just the Libgdx Mesh not rendering. I tested the Shader on a spriteBatch, and it works just fine. The mesh just does nothing with the render Method, not even a graphic bug... Do you have any idea what the issue could be? here...

Libgdx: Objects creating other objects

java,android,architecture,libgdx
I have kind of a general question about a simple game architecture. In my game I have these classes: Main class who's responsible for drawing and rendering. Ball object which has a few attributes and update() function that does certain things. The main class has an array of all exist...

Check if finger is over actor - libgdx

java,android,button,libgdx,touch
I'm trying with this but I don't know how can I get the boolean from here. button.addListener(new InputListener() { public boolean touchdown; @Override public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) { touchdown=true; } @Override public void exit(InputEvent event, float x, float y, int pointer, Actor...

TextArea.continueCursor(TextArea.java:331) / ArrayIndexOutOfBoundsException: 16

user-interface,libgdx,thread-safety,indexoutofboundsexception
What could be the cause of this error? (Can't figure it out) Exception in thread "LWJGL Application" java.lang.ArrayIndexOutOfBoundsException: 16 at com.badlogic.gdx.scenes.scene2d.ui.TextArea.continueCursor(TextArea.java:331) at com.badlogic.gdx.scenes.scene2d.ui.TextArea.calculateOffsets(TextArea.java:278) at com.badlogic.gdx.scenes.scene2d.ui.TextField.draw(TextField.java:283) at com.badlogic.gdx.scenes.scene2d.Group.drawChildren(Group.java:124) at com.badlogic.gdx.scenes.scene2d.Group.draw(Group.java:58) at...

LibGDX- Unexpected computing by libgdx

java,libgdx
i recently had problems of FPS drop (~40 FPS), and when i searched where it was. I saw that it wasnt me, all my calculation were done in 7 ms which is far from the 16 ms limit. This is the code i used : long time = 0; public...

y axis in the middle of screen

android,libgdx
Hi I have a simple code: public class MyGdxGame extends ApplicationAdapter { SpriteBatch batch; Texture texture; BitmapFont font; GameObject gameObject1; GameObject gameObject2; @Override public void create () { texture= new Texture("badlogic.jpg"); batch= new SpriteBatch(); font = new BitmapFont(); font.setColor(Color.GREEN); gameObject1= new GameObject(texture); gameObject2= new GameObject(texture); gameObject1.x=0; gameObject1.y=0; gameObject2.x=400; gameObject2.y=400; gameObject2.height=gameObject2.getTexture().getHeight();...

Saving Sprite Position

java,libgdx,position,sprite
I have a sprite that when reaches a certain position it gets removed: if(sprite.getY()>=700){ enemyIterator.remove(); Pools.free(sprite); } I wan't to save the last position of the sprite before it gets removed,I tried sprite.getX() and sprite.getY() but those are only usable while the sprite is in the game....

how to implement multiple(for different game levels) leaderboard in android libgdx game?

android,libgdx,google-play-services
I am having 3 different game levels.So there would be three different high scores that need to be posted for Leaderboard on google play services. I dont understand this. what I did is that I have created a method public void submitScoreGPGS(int score); { Games.Leaderboards.submitScore(gameHelper.getApiClient(),"id", score); } public void getLeaderboardGPGS()...

Loading external resources

java,android,libgdx,loading
I'm loading all of my resources in a Loading Screen with the LibGDX AssetManager. The problem I'm having is that the AssetManager only manages internal resources, and most of my resources are external (pictures stored the user's phone), so I have to load them aside (just like that : texture...

Is it possible to modify libgdx's Table cells?

libgdx
I'm using libgdx Table to show some info. This information can change sometimes. I would like to change the cells so that they reflect the updated values. Is this possible or are Tables designed to be static? To clarify, I would like to do is something like this: class MyTable...

Calculation position of a Vector between two others

java,math,libgdx
I think my current problem is related to intercept theorems that everybody learned at school, but that was quite some time ago and I am kind of getting stuck halfway. My Problem: I have two Vectors in a 2 dimensional space called v1 and v2. What I want to know...

Libgdx : Detect empty TextureRegion

java,libgdx,textures
I've been building a little game in Libgdx for a couple of days now and I wanted to implement some kind of dynamic sprite-analyzer. I have a png-file that I split into TextureRegions and build a Animation out of. So I split up the Image in 64x64 Regions and iterate...

Delaunay triangles point connectivity?

java,libgdx,triangulation,procedural-generation
I was watching this video: Delaunay Triangulation and I want to use this to generate procedural content in the same way. I had a pretty hard time figuring out how to work with the DelaunayTriangulation class supplied by LibGDX but I guess I finally figured it out. My question however...

Java : LibGDX AppHangB1 error

java,libgdx,box2d
I am developing a game using Java - LibGDX framework , Box2D physics engine . And when I play my game from several time I get this error, the game crashes . What can cause this error? ...

LibGDX random error [closed]

java,intellij-idea,libgdx
I just installed LibGDX on IntelliJ IDEA, and once I run the application, it gives me this error: Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: badlogic.jpg at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140) at com.badlogic.gdx.graphics.TextureData$Factory.loadFromFile(TextureData.java:98) at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100) at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:92) at...

Box2d Body to follow mouse movement

libgdx,box2d,game-physics
I am trying a box2d body to rotate following the mouse. Here's an image to clarify what I mean. The red and blue circles are current point of the mouse and the body (of corresponding color) moving/rotating to follow it. Basically the rectangle should rotate with its one end pointed...

AsyncTask in LibGDX - example

java,asynchronous,libgdx
Did anyone used AsyncTask with AsyncResult and AsyncExecutor in LibGDX? I want to run some audio recording and processing asynchronously with checking if result is ready. This is part of my code: private FftAnalysis analysis; private AsyncExecutor executor; private AsyncResult<Double> asyncResult; (...) public GameWorld(int midPointY) { executor = new AsyncExecutor(300);...

libGDX pause running for some seconds

java,android,libgdx
I have an application, in which I would like to make a short pause. It would be important, to make graphical elements/changes better visible between two automatic interactions. I have tried to use above code above for 2 minutes of pause, but it causes a pause at the start of...

How do I remove Sprites when they go on a specific position?

java,libgdx,position,sprite
My Sprite are spawned at a random time, after being spawned the the move upward until they get on a certain position then they should be removed. That's what I've been trying to do but I always get an error. //this method is called at random time public void newEnemy(){...

Imagebutton one on top of another can't click the one underneath the other - Scene2d LIBGDX

java,libgdx,scene2d
I have two ImageButtons one on top of the other. Depending on events in my game I fadeOut one of the buttons and fadeIn the other, and vice versa. The problem is that the buttons are placed in a Stack at exactly the same position and the button underneath does...

Libgdx sprite size matching screen size

java,libgdx,size,screen,scaling
So i have a created a background which is 1920 x 1080 in size. And i have a window that is 1280 x 720 (will not always be this size) Now when i render the sprite using this code: @Override public void render(float delta) { Gdx.gl20.glClearColor(0.2F, 0.5F, 1F, 1F);...