libgdx

Centering a texture LibGDX

ぐ巨炮叔叔 提交于 2019-12-12 13:22:12
问题 I am trying to center a 256px X 256px image in LibGDX. When i run the code I'm using it renders the image in the upper right hand corner of the window. For the camera's height and width I use Gdx.graphics.getHeight(); and Gdx.graphcis.getWidth(); . I set the cameras position to the camera's width divided by the two and its height divided by two... this should put it in the middle of the screen right? when I draw the texture, I set it's position to the camera's width and height divided by two

What exactly is “tools.jar” in the Android SDK?

老子叫甜甜 提交于 2019-12-12 13:03:12
问题 So, I've been trying to build a project in LibGDX for about 10 hours now. In case you'r unfamiliar, LibGDX is one of those platforms where you specify a project directory at the start, along with any required SDKs and then when you're ready to start coding it will generate a project for you. Anyway, I've been having a problem where every time I try to build it fails with the single error message: Execution failed for task :core:compileJava. Could not find tools.jar I'm guessing "tools.jar" is

Android application using libgdx crashes since update to ADT 17

依然范特西╮ 提交于 2019-12-12 12:29:26
问题 My Android program crashes. This started after updating Eclipse to 3.6.2 and updating the SDK and ADT (to 17), I had a problem. (After I updated eclipse, my ddms crashed too, but i fixed that.) I've now updated my SDK and ADT to 18, but I still have this problem. My lib folders in my Java project and Android project haven't changed. I use Mario tutorials and build those. My java project runs well, but I don't understand why my Android projects cant run. Crash screenshot in my phone: LogCat in

getResourceAsStream() returns null

梦想的初衷 提交于 2019-12-12 12:29:17
问题 I have the following problem InputStream input = FileHandle.class.getResourceAsStream("/data/sounds/back.ogg"); returns null, but InputStream input = FileHandle.class.getResourceAsStream("/data/sounds/back.png"); returns InputStream, also both files are in this folder. What can be wrong? I'm using libgdx-0.9.6 回答1: If your path starts with "/", java will search your file in the root of your file system. If it is in your root folder, first of all, check if file exists: ls -l /data/sounds/ |

crop image using libgdx

隐身守侯 提交于 2019-12-12 12:24:13
问题 I need to crop image like this I need to draw partial image from center I know there is draw() method of batch with a lot of params, but there is no good documentation about all this params, so i can't figure out how to use it. Here is what i implemented: public class TexturePart { Texture tex; Vector2 position; // Target Dimension of image int targetWidth; int targetHeight; // Src Dimensions of Image int srcWidth; int srcHeight; int srcX; int srcY; // Ratio of dimension of target and source

Libgdx couldnt load shared library gdx freetype for target linux 32bit, how do I fix?

岁酱吖の 提交于 2019-12-12 12:09:34
问题 I have started using libgdx and have been trying to get the freetypefont working on Android but no matter how hard I try I cannot seem to get it working. My app was working perfectly fine until I tried using freetypefont. I have put the extensions in as directed on the libgdx web site. The app crashes or stops working as soon as it starts. The console says couldn't load shared library gdx-freetype for target linux 32-bit. I feel like I have tried everything. I have put the two freetype and

LibGDX / LWJGL start application maximized

廉价感情. 提交于 2019-12-12 11:35:05
问题 cfg.fullscreen=true; makes it totally fullscreen. cfg.width = Gdx.graphics.getWidth(); cfg.height = Gdx.graphics.getHeight(); makes it so the size is the screen size but it is still not maximized(I can hit the little box on the top right to make it snuggly locked into the screen. I just realized this was a nuisance after I launched my program several times and had to keep maximizing it. Is there a simple way to... cfg.startMaximized=true? 来源: https://stackoverflow.com/questions/23029588

Libgdx SpriteBatch.draw() specifying 4 vertices

懵懂的女人 提交于 2019-12-12 11:17:54
问题 I'm using libGdx to create a 2d game and am trying to use this particular method to draw a simple 2d texture, specifying the 4 vertices induvidually; draw(Texture texture, float[] spriteVertices, int offset, int length) description says: Draws a rectangle using the given vertices. There must be 4 vertices, each made up of 5 elements in this order: x, y, color, u, v. Other draw methods work fine, but I can't get this one to work. What im trying is this; batch.draw(boxTexture, new float[] {-5,

Mesh rendering issue libgdx

▼魔方 西西 提交于 2019-12-12 11:05:39
问题 I have a very simple program, that loads an wavefront obj file, rotate and displays it. The problem is that the program renders it with some issues (like missing triangles). I had a similar problem when I tried to render a Pyramid with a vertex buffer taken from NeHe's tutorial. So I don't know what cause this rendering issues. Can you help me? package com.jam.libgdx3DTest; import com.badlogic.gdx.Game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.*; import com.badlogic.gdx

How to handle null compare method arguments in Comparator?

懵懂的女人 提交于 2019-12-12 10:55:31
问题 I have created an implementation of Comparator<Entity> , but when I use this comparator to sort an Array<Entity> . I will receive an java.lang.NullPointerException , because when I map the entity to a static collections which is already removed. Now my problem is I don't know what to return to skip the compare method. public class CustomComparator implements Comparator<Entity> { public int compare(Entity e1, Entity e2) { if( e1== null || e2 == null) { return // don't know what to return to