libgdx

Why can't I launch my LibGDX project on html?

不羁的心 提交于 2019-12-12 10:46:10
问题 So, I made a libgdx project trough the gradle setup and programmed my game. When i launch it on desktop, everything is ok, but when I try to run the html I get the following error: :html:draftCompileGwt FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':html:draftCompileGwt'. > Process 'command 'C:\Program Files\Java\jdk1.8.0_25\bin\java.exe'' finished with non-zero exit value 1 * Try: Run with --stacktrace option to get the stack trace. Run with -

Reuse code when using screens in Libgdx

可紊 提交于 2019-12-12 10:37:55
问题 From what I understand when reading other peoples code on how to make different screens. You do a main handler class sort of... And then create a new class for each screen. The thing that confuses me is that whenever you create a new screen, you have to redefine everything that's going to be rendered, like SpriteBatch, sprites, fonts, etc. Is there any way to reuse these kind of things in all screens? I mean, if I have 10 screens, and want to be able to draw text on every screen. Is it really

How to set portrait mode with libGDX?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 10:28:51
问题 I've created a game, and it is OK in desktop mode, but when i launch it on my S3, it goes in landscape mode, how can i change it? Thank you in advance 回答1: android:screenOrientation: landscape portrait unspecified behind reverseLandscape reversePortrait sensorLandscape sensorPortrait For more information you can visit: Android Activity Element 回答2: Have a look at the <activity> element. You can set the orientation as: android:screenOrientation=["unspecified" | "behind" | "landscape" |

Importing “google-play-services_lib” into Eclipse crashes libgdx project

China☆狼群 提交于 2019-12-12 10:17:59
问题 I am trying to add google ad banners for my libgdx android game. After following the guide https://github.com/libgdx/libgdx/wiki/Google-Mobile-Ads-in-Libgdx-(replaces-deprecated-AdMob) and importing "google-play-services_lib" the game can't be started anymore. I am using Eclipse Luna. Eclipse keeps loading until death. 回答1: For the proper import do it this way: File -> Import -> Existing Android Project -> Browse the "google-play-services_lib" folder then make sure you have checked the "Copy

CCRenderTexture,GL11ExtensionPack,Libgdx How TO

走远了吗. 提交于 2019-12-12 10:16:45
问题 I currently work on a effect such as "Tiny Wings" http://www.raywenderlich.com/3857/how-to-create-dynamic-textures-with-ccrendertexture ,and find CCRenderTexture is the solution. So I want to know how to make this effect on android , finally I found this link https://github.com/ZhouWeikuan/cocos2d/blob/master/cocos2d-android/src/org/cocos2d/opengl/CCRenderTexture.java It shows that its GL11ExtensionPack GL11ExtensionPack egl = (GL11ExtensionPack)CCDirector.gl; egl.glGetIntegerv

taking screenshot in libgdx

假如想象 提交于 2019-12-12 09:44:26
问题 I have an application in which i want to take the screenshot of the game screen and save it as an image and upload to Facebook. I am using Libgdx and my focus is android. Can anyone help me that how to take screenshot of the game screen programmatically and save it as an image ?? 回答1: It is now fairly easy. Libgdx provides an example, which can be found here. I had to add one statement to get it working. The image could not be saved directly to /screenshot1.png . Simply prepend Gdx.files

Creating Texture in headless LibGDX unit tests

允我心安 提交于 2019-12-12 09:37:13
问题 I am using the LibGDX headless backend to run jUnit tests. This works well for certain tests, but if I try to create a new Texture('myTexture.png'); , I get a NullPointerException. The exact error is: java.lang.NullPointerException at com.badlogic.gdx.graphics.GLTexture.createGLHandle(GLTexture.java:207) To keep things simple, I created a method that does nothing other than load a texture: public class TextureLoader { public Texture load(){ return new Texture("badlogic.jpg"); } } Then, my

libgdx How do I scale a BitmapFont to changing screen sizes?

爱⌒轻易说出口 提交于 2019-12-12 09:16:34
问题 What I want to have is the Bitmap Font to change in size accordingly when changing screen sizes. What I mean is on my computer, the font appears rather large, but on my phone, it is a little font that is harder to read. I could change the size, but I want it to look similar on all screens, instead of having it large on one screen and smaller on another. Here is my code to see what I have to work with: public void render() { //score system scoreFont.setColor(1.0f, 1.0f, 1.0f, 1.0f); scoreBatch

Flickering object image movement in libgdx desktop app

孤街醉人 提交于 2019-12-12 09:14:44
问题 This code makes image flicker while moving left,right,down or up. public class MoveSpriteExample extends GdxTest implements InputProcessor { Texture texture; SpriteBatch batch; OrthographicCamera camera; Vector3 spritePosition = new Vector3(); Sprite sprite; public void create() { float w = Gdx.graphics.getWidth(); float h = Gdx.graphics.getHeight(); batch = new SpriteBatch(); camera = new OrthographicCamera(); camera.setToOrtho(false, w, h); texture = new Texture(Gdx.files.internal("data

Libgdx pause/resume not called when window is being dragged (Windows)

不羁岁月 提交于 2019-12-12 08:48:46
问题 I am creating a Java game with libgdx. Really liking the engine so far but I noticed an issue when dragging the game window. Rendering seems to stop (which is okay) but I cant find any events that get called during this state. Is there any way I can trap it? It not a big deal for rendering as I cap the deltaTime, but for input the keyUp events don't get fired which messes up my movement code for the player (if you are to release the keys while dragging the window). Is there anything I can do?