libgdx

LibGdx: Utilizing a Gesture Listener

China☆狼群 提交于 2019-12-14 03:55:51
问题 I would like to use some of the more complex touch screen gestures that you can't access from Gdx.input I saw that to do this i must create a Gesture listener so i created the class GestureHandler and copied the code from the wiki. My gesture handler looks like this: public class GestureHandler implements GestureListener { @Override public boolean touchDown(float x, float y, int pointer, int button) { return false; } @Override public boolean tap(float x, float y, int count, int button) {

How to add libgdx to existing project

早过忘川 提交于 2019-12-14 03:49:51
问题 I have provided an aplication made in android that has a navigation drawer and in it has a list of games. I have to create another game and to put it there. The game that has to be created by my must use libGDX but the original application didn't use this library. Is it possible to do this ? If Yes, how can I add the libgdx to the exiting project. On github I found only how to start a new project with libGDx, an not how to add it to exising code. thanks. 回答1: Generally what you want is

How to handle Null Pointer Exception in libGDX's Box2D ContactListener?

你说的曾经没有我的故事 提交于 2019-12-14 03:23:08
问题 What's up everyone, I am heuristically producing a Pong clone in Box2D via libGDX. The Null Pointer Exception is originating in the ContactListener's beginContact() method in which I am trying to implement score logic. The Box2D world uses two separate EdgeShapes as sensors for incrementing a score variable upon collision with the Ball (view attached image). The collision logic between the Ball and the two EdgeShapes works, but collision between the Ball and anything else in the Box2D world

Controlling and creating multiple sprites array Java Libgdx

时光怂恿深爱的人放手 提交于 2019-12-14 02:14:12
问题 I am trying to create a game which has sprites and every second another is spawned, i tried using this as a base: https://github.com/libgdx/libgdx/wiki/A-simple-game However when the new one spawns in it destroys the old one and they start to spawn faster and faster. Here is the relevent code: ownCreate method: Array<Rectangle> chickens; chickens = new Array<Rectangle>(); spawnChicken(); New Spawn Chicken method: private void spawnChicken() { int choice; choice = MathUtils.random(0, 3);

LibGDX: The relationship between Screen interface and Game class

百般思念 提交于 2019-12-14 00:13:19
问题 I want to understand the relationship between the Game class and the Screen Interface. In the textbook I am reading, it states that the Game class delegates the functions from ApplicationListener to a screen object. And somehow this allows you to switch screens. I don't get it, why does this happen and how does it work? My current understanding: Game implements Life Cycle methods from ApplicationListener(Create(), Render(), etc...). But the reason you don't just implement from

How to draw several copies of the same actor on one stage at different positions?

二次信任 提交于 2019-12-13 21:20:57
问题 I want to draw several copies of an actor on the same stage. Here what I've done : // class Test public class Test extends Image { private Sprite sprite; private Rectangle bounds; private final float HEIGHT = Gdx.graphics.getHeight(); public Test() { // Sprite Texture texture = new Texture("img.png"); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); sprite = new Sprite(texture); // adjusting sprite size to different resolutions float imgHeightRatio = 120.0f / 480.0f; float

LibGDX game lags when rendering

亡梦爱人 提交于 2019-12-13 21:05:01
问题 I have an array of obstacles ( Array of Vector2 objects) which move from the right side of the screen to the left so in every call of render() function I decrement their x-positions by 400*deltaTime value and then I am drawing them using SpriteBatch . The problem is when they are moving left sometimes some obstacle lags so it looks like it moves to the right for a while or it stops and I don't know why. So they are moving left and some obstacle stops for a while then they are moving correctly

libgdx open gles 2.0 stencil alpha masking

孤者浪人 提交于 2019-12-13 20:43:21
问题 I'm looking for a solution to implement alpha masking with stencil buffer in libgdx with open gles 2.0. I have managed to implement simple alpha masking with stencil buffer and shaders, where if alpha channel of fragment is greater then some specified value it gets discarted. That works fine. The problem is when I want to use some gradient image mask, or fethered png mask, I don't get what I wanned (I get "filled" rectangle mask with no alpha channel), instead I want smooth fade out mask. I

Cannot run libgdx's 'Animation3DTest' on Android

喜欢而已 提交于 2019-12-13 20:09:18
问题 I am trying to run the Animation3DTest , one of libgdx's test examples On the desktop (lwjgl) I can run this test flawlessly, I can see a guy and a sword and I can move him around without any errors. However, on Android, after starting this test, I got a force stop, and here is what showed on the Logcat 09-24 10:46:49.526 24530-24577/com.badlogic.gdx.tests.android E/AndroidRuntime﹕ FATAL EXCEPTION: GLThread 1445 com.badlogic.gdx.utils.GdxRuntimeException: File not found: com/badlogic/gdx

Android Studio Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.4-all.zip'

自闭症网瘾萝莉.ら 提交于 2019-12-13 19:52:15
问题 I'm developing a libgdx game. The code is compiling successfully, but after hitting run, the build failed, and showing error like this Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.4-all.zip'. Have anyone got solution for this? 回答1: Hopefully you've created your LibGDX project using gdx-setup.jar of latest build. If yes try to update your gradle version to 4.6 Check and update the gradle/wrapper/gradle-wrapper.properties file in your