libgdx

libgdx tiledmap flicker with Nearest filtering

笑着哭i 提交于 2019-11-28 05:46:40
问题 I am having strange artifacts on a tiledmap while scrolling with the camera clamped on the player (who is a box2d-Body). Before getting this issue i used the linear filter for the tiledmap which prevents those strange artifacts from happening but results in Texture bleeding (i loaded the tiledmap straight from a .tmx file without padding the tiles). However now i am using the Nearest filter instead which gets rid of the bleeding but when scrolling the map (by walking the character with the

Libgdx background and foreground in single stage

醉酒当歌 提交于 2019-11-28 05:40:07
问题 My requirements: Background filling entire physical screen (stretching if required) Preserve aspect ratio of foreground assets (Work with virtual width and height) For this, I use two Stages in my Screen as shown in the code below. public void render(float delta) { backgroundStage.act(delta); backgroundStage.draw(); foregroundStage.act(delta); foregroundStage.draw(); } public void resize(int width, int height) { background.setWidth(width); background.setHeight(height); backgroundStage

When to use actors in libgdx? What are cons and pros?

蓝咒 提交于 2019-11-28 04:24:04
I'm writing simple solar system simulator. This is my first libgdx project. I'm using a Stage and Actors for the main menu and is pretty handy especially touch events handling. But ... looking at the examples i see nobody uses actors in actual game logic. I wander if i should use actor as a parent of planet class or just write my own class tor that. The planets won't be touchable and they will be moved only between the frames so the third parameter of action MoveBy will have to be time between frames. That are the cons. What are the pros for using Actors? The main pros for Actors are Actions,

In libgdx, how do I get input from the back button?

三世轮回 提交于 2019-11-28 04:19:49
For my game, I'd like the Android back button to take you to the pause menu, instead of minimizing the game. From what I've googled, I know I need to call Gdx.input.setCatchBackKey(true); But how do I actually check for the button press? input.isKeyDown(Keys.BACK) doesn't seem to do anything. I solved the problem like this: public class MyApplication implements ApplicationListener, InputProcessor { // !! Remember to override all other required methods !! ... @Override public void create() { Gdx.input.setInputProcessor(this); Gdx.input.setCatchBackKey(true); // rest of your stuff... } ...

Get Firebase to work with java, not Android

你说的曾经没有我的故事 提交于 2019-11-28 03:54:48
问题 Im trying to get a libgdx project up and running and I want to firebase for user logins. I'm finding that the SimleLogin class is depending on Android.jar. Is there a way around this as I would like to have a desktop java application running as well as android. Here is the code that is causing the issue: SimpleLogin authClient = new SimpleLogin(myRef);; authClient.createUser("myuser@gmail.com", "much wow", new SimpleLoginAuthenticatedHandler() { @Override public void authenticated

how to flip a pixmap to draw to a texture in libgdx?

孤街浪徒 提交于 2019-11-28 03:08:18
问题 So what I'm trying to do is to generate a background image for my game by drawing pixmaps to a texture. So far I can do that, but now I need to draw the pixmaps flipped in the X or Y axis to the texture. However I can't find anything to do so. The pixmap class does not provide that functionality. Then I thought I could draw a flipped texture region to a texture, but so far I haven't found how to do so. So I was wondering how can I do such a thing, would it be possible to flip a png image with

Button ClickListener is not working in LibGDX game

倾然丶 夕夏残阳落幕 提交于 2019-11-28 02:37:20
问题 I am developing an Android game using LibGDX. There are 4 buttons in a menu screen, but the ClickListener of these buttons is not working. // retrieve the custom skin for our 2D widgets Skin skin = super.getSkin(); // create the table actor and add it to the stage table = new Table( skin ); table.width = stage.width(); table.height = stage.height(); stage.addActor( table ); // retrieve the table's layout TableLayout layout = table.getTableLayout(); // register the button "start game"

Libgdx Box2D pixel to meter conversion?

谁都会走 提交于 2019-11-28 00:30:24
When trying to program a game using Box2D, I ran into a problem with Box2D. I filled in pixel numbers for the lengths of the the textures and sprites to create a box around it. Everything was at the right place, but for some reason everything went very slowly. By looking on the internet I found out that if you didn't convert pixels to meters box2d might handle shapes as very large objects. this seemed to be a logical cause of everything moving slowly. I found similar questions on this site, but the answers didn't really seem to help out. in most of the cases the solution was to make methods to

Could not find class XXX referenced from method XXX.<YYY>

回眸只為那壹抹淺笑 提交于 2019-11-27 23:26:19
I'm working on a libGDX project and I have a class called CheerVArachnids that has another inline class which is an event listener. When I run this project on the desktop it works fine. BUT when I run on my Android device, it can't find that inline class and I get the following error: Could not find class 'com.bbj.cva.CheerVArachnids$PlaceUnitListener', referenced from method com.bbj.cva.CheerVArachnids.<init> Here are the important parts of my class: package com.bbj.cva; public class CheerVArachnids implements ApplicationListener { class PlaceUnitListener implements EventSubscriber

How do I detect if a sprite was touched in Java libGDX?

房东的猫 提交于 2019-11-27 22:32:56
In the past few days I've been porting my game ( Apopalypse ) to the Android Mobile platform. I've did a quick search on Google of sprite touch detection but didn't find anything helpful. Each balloon will pop once touched and I just need to detect if it's touched. Here's my balloon spawning code: Rendering (x, y, width, and height are randomized): public void render() { y += 2; balloon.setX(x); balloon.setY(y); balloon.setSize(width, height); batch.begin(); balloon.draw(batch); batch.end(); } Spawning in main game class: addBalloon(new Balloon()); public static void addBalloon(Balloon b) {