libgdx

What is the difference between “Game”, “Screen” and “ApplicationAdapter” in libgdx?

こ雲淡風輕ζ 提交于 2019-12-21 04:20:33
问题 In tutorials sometimes people use "extends Game", sometimes "implements Screen" and i have auto-generated "extends ApplicationAdapter". What is the difference between them? 回答1: ApplicationAdapter allows you to create a listener, but not being forced to implement every method. If you're familiar with Swing, check out KeyAdapter , it's the same idea. An ApplicationListener allows you to handle application events. This allows you to execute code during certain events within the application life

adding Admob to Libgdx game

早过忘川 提交于 2019-12-21 04:13:26
问题 I was fallowing this tutorial but when I tried to go to monetize page I wasn't able to monetize or add any banner because my game isn't in the store unlike the tutorial. My question is: do I need to upload my game without adding the code of admob then add it latter to my game or shall I add the code before uploading it then set the things from admob website? It might be a silly question but I'm just a newbie when it comes to admob 回答1: There is a hole section in Libgdx official docs that

Libgdx project Exception in thread “LWJGL Application”. Couldn't load file. Error log inside

こ雲淡風輕ζ 提交于 2019-12-20 13:01:09
问题 I am a newbie in libgdx and just got it setup in android studio. Now I am getting this error when I press run for the first time. /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bin/java Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: badlogic1.jpg at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140) at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64) at com.badlogic.gdx.graphics

Is there a way for push notifications in libGDX (Android and iOS projects)?

时光总嘲笑我的痴心妄想 提交于 2019-12-20 12:41:27
问题 Does someone knows if it is possible to add push notifications(like Amazon Simple Notification Service) in an Android and iOS with RoboVM libGDX projects? And if it is possible, are there any good tutorials or good hints how to implement such things? I would be happy about every hint how I can implement it. 回答1: Hi I know this is an old question but I was struggling to find a solution for this specially for iOS, but I finally found a way. If the explanation below is confusing and you prefer

LibGDX and ScrollPane with multiple widgets

浪子不回头ぞ 提交于 2019-12-20 12:25:07
问题 Trying to add multiple items to a scrollpane I quickly found that all "addActor" functions are Unsupported. So, I went with adding a table with all the items I wanted (this code misses a image that I still want to add) to make a scrollable credits screen... but this approach (currently) doesn't allow for overflow, rendering the ScrollPane useless. (My text is only shown up to what the screen's height allows, and isn't scrollable). What's the way to make a scrollable pane with multiple widgets

How to restart screen in LibGDX using Init() methods?

夙愿已清 提交于 2019-12-20 07:15:55
问题 I created a simple game in LibGDX that has multiple screens. I want to restart a certain screen after touching a restart button but I'm not sure how to do that. I made some research about this and all answers lead to not loading my assets in show() but rather in an init() method that I am not really familiar with. I want to know how can I restart a screen using this init() method . As of now I put most of my initialization in the constructor and some were initialized in methods such as the

Load image with libgdx

不羁岁月 提交于 2019-12-20 06:14:19
问题 I am trying to load two images on the java application built by libgdx library. I loaded the background image however, I could not load the other images on to the screen if I am not set the position of the images to (0,0). For example; I set the position of the image to 0,0 and there is no problem. However, when I set the position of the image to 20, 0, it cannot be seen. batch.draw(Assets.coinRegion, position.x, position.y, 1, 1) I am trying to draw the image with the above code. Thank you.

LibGdx texture drawn as inverse of what #getTextureData gives

ⅰ亾dé卋堺 提交于 2019-12-20 06:11:31
问题 I've been trying to resolve this issue I have been having with displaying a texture correctly on my libgdx desktop program. I have an Orthographic camera with which when I set as: camera.setOrtho(false); I get this image: And when I set it as: camera.setOrtho(true); I get this image: The red image is drawn with a SpriteBatch: batch.draw(texture, x, y, width, height); While the white image is drawn from individual points plotted based on if their alpha value was 1. TextureData td = texture

Drawing pause Screen as a layer over the play screen-LibGdx

谁说胖子不能爱 提交于 2019-12-20 05:49:07
问题 In my LibGdx Game I created pause functionality.While playing game,If I press pause button,a separate screen with resume button displays. What actually I want to do is that the pause screen should appear above the game play screen like a layer. Like the screen shot of a game below: I could only make a new pause screen in my game with separate bg and all. I want to display the paused game as it is.Above that I can draw graphics for resume button,box etc exactly like the screen shot. How can I

libgdx decal dynamic text

ε祈祈猫儿з 提交于 2019-12-20 05:46:07
问题 I'm working on 3D (2.5D) application in Libgdx. I've found Decals very useful for this purpose. In my app there should be layers, that contain dynamical text, now I'm wondering what is the best way to draw text via Decals. Currently my implementation is based on drawing BitmapFont to FBO, then I get FBO texture and bind it to Decal before DecalBatch.flush(). I think that this is maybe not the most efficient way of doing this, but can't figure out better way. My app can contain large number of