libgdx

Headless/CLI LibGDX

谁都会走 提交于 2019-11-30 14:15:16
I'm coding the server-side for a small LibGDX powered game, and have stumbled across an issue. Every time I try and use any Gdx.files.* methods, I'm met with a NullPointerException . Apparently this is because I'm not implementing the ApplicationListener, so LibGDX has not been initialized. Is there any way of initializing LibGDX in a headless/CLI way? I need to be able to load TiledMap objects on the server-side. MapLoader(Request request) { TiledMap tmp = new TmxMapLoader().load("maps/" + request.name + ".tmx"); } Exception in thread "Server" java.lang.NullPointerException at com.tester

LibGDX's TexturePacker with gradle

只愿长相守 提交于 2019-11-30 13:51:06
I am attempting to create a gradle task which runs TexturePacker according to the instructions here . (Note that I am using Android Studio and its directory structure rather than Eclipse.) I first added the following to the Android Studio project's build.gradle : import com.badlogic.gdx.tools.texturepacker.TexturePacker task texturePacker << { if (project.ext.has('texturePacker')) { logger.info "Calling TexturePacker: "+texturePacker TexturePacker.process(texturePacker[0], texturePacker[1], texturePacker[2]) } } This gave the error unable to resolve class com.badlogic.gdx.tools.texturepacker

Putting Freetypefont into libgdx skin

家住魔仙堡 提交于 2019-11-30 11:39:27
In my uiskin.json I have this com.badlogic.gdx.graphics.g2d.BitmapFont: { default-font: { file: text/default.fnt } } This is fine for when I have the default.fnt in my text folder in the assets folder... However I want to use a Freetypefont. How do I create a Freetypefont and load it into the uiskin file? It is not possible to do it beforehand, since you are going to generate it at runtime. My workaround would be to keep the default font as it is and replace it at runtime via code. You can use Skin.add(...) for that. BitmapFont newDefaultFont = FreeTypeFontGenerator...; skin.add("default-font"

Libgdx How to get a list of files in a directory?

孤者浪人 提交于 2019-11-30 11:24:54
So I am trying to get a list of files in a directory with a file handle.list() method but it returns an empty list even though there are files in the directory. What seems strange to me is that it does work on the device but it does not work on the desktop. I think I know what the problem is but I dont know how to solve it though. In the method description it says "On the desktop, an FileType.Internal handle to a directory on the classpath will return a zero length array.", but there is no other method than this so what do you guys think I can do? P.T. The "internal files" are found via the

Drawing a gradient in Libgdx

≡放荡痞女 提交于 2019-11-30 11:20:09
Ok I have this code @Override public void render() { // do not update game world when paused if (!paused) { // Update game world by the time that has passed // since last render frame worldController.update(Gdx.graphics.getDeltaTime()); } // Sets the clear screen color to: Cornflower Blue Gdx.gl.glClearColor(0x64/255.0f, 0x95/255.0f, 0xed/255.0f, 0xff/255.0f); // Clears the screen Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); // Render game world to screen worldRenderer.render(); } And it draws a light blue background onto the screen. I am attempting to create a gradient that goes from a dark blue

Understanding the libGDX Projection Matrix

孤人 提交于 2019-11-30 11:06:18
Over the past few weeks I've been attempting to learn the libGDX library. I'm finding it hard, especially for my first endeavor toward game development, to comprehend the system of Camera/viewport relationships. One line of code that I've been told to use, and the API mentions, is: batch.setProjectionMatrix(camera.combined); Despite a good 4 hours of research, I'm still lacking a complete understanding of the functionality of this code. It is to my basic understanding that it "tells" the batch where the camera is looking. My lack of comprehension is depressing and angering, and I'd appreciate

LibGDX - How to integrate AdMob for both iOS and Android

早过忘川 提交于 2019-11-30 09:49:07
I am following this tutorial for AdMob integration through LibGDX, but it shows for Android only. I am just wondering if someone has an example how to achieve same integration including iOS? Also, how can I use banners instead of full screen? Currently my setting for iOS with LibGDX is: 1.- RoboVM read this link It also includes many other useful integration related to ios and libgdx. 来源: https://stackoverflow.com/questions/22025629/libgdx-how-to-integrate-admob-for-both-ios-and-android

Error while importing projects

一笑奈何 提交于 2019-11-30 08:45:47
While importing projects into eclipse i have this error: Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory. Could not execute build using Gradle distribution ' http://services.gradle.org/distributions/gradle-1.11-all.zip '. As I have checked i need to set JAVA_HOME (i have the JDK on my computer), but i dont have a clue how to do that. I had lots of similar problems and I think that the best solution is to specify JDK location manually. In order to do it: Add two files to

How to resize a sprite in Libgdx?

て烟熏妆下的殇ゞ 提交于 2019-11-30 08:14:55
I have a problem with the method sprite.setSize(float x, float y) in Libgdx. It does not affect the size or the dimensions of the sprite. They remains fixed whatever I pass to the setSize() method. here is my code : public class GameScreen implements Screen { OrthographicCamera camera; SpriteBatch batch; Texture carTexture; Sprite carSprite; public GameScreen() { } @Override public void render(float delta) { // TODO Auto-generated method stub Gdx.gl.glClearColor(0,0,0,0); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); batch.begin(); carSprite.setSize(16, 32); batch.draw(carSprite, 0 , 0); batch.end

Drawing filled polygon with libgdx

纵然是瞬间 提交于 2019-11-30 07:23:41
i wanted to draw some (filled) polygons with libgdx for an android game. it shoudn't be filled with a graphic/texture. i have only the vertices of the polygon (closed path) and tried to visualize with meshes but at some point this is not the best solution, i think. my code for an rectangle is: private Mesh mesh; @Override public void create() { if (mesh == null) { mesh = new Mesh(true, 4, 0, new VertexAttribute(Usage.Position, 3, "a_position") ); mesh.setVertices(new float[] { -0.5f, -0.5f, 0 0.5f, -0.5f, 0, -0.5f, 0.5f, 0, 0.5f, 0.5f, 0 }); } } ... @Override public void render() { Gdx.gl