libgdx

LibGdx TmxMapLoader load external files

倖福魔咒の 提交于 2020-01-25 16:43:49
问题 I tried to load an TiledMap from the sdcard. In TmxMapLoader.java is says... * Loads the {@link TiledMap} from the given file. The file is resolved via the {@link FileHandleResolver} set in the * constructor of this class. By default it will resolve to an internal file. So, how can I change the default value to external? Thank you 回答1: You can provide custom FileHandleResolver in constructor: TiledMap map = new TmxMapLoader(new ExternalFileHandleResolver()).load("level1.tmx"); More info about

libgdx spritebatch not rendering textures

情到浓时终转凉″ 提交于 2020-01-25 11:06:44
问题 I'm working on a top down RPG game using LibGDX, and am creating an Ortho.. camera for my game. However in doing so, only my tile textures render now. This is how the render code looks: Camera initialized as new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); (note that the camera. calls are actually in the world.update method, I just figured I would minimize the amount of code needed on here) Updating/Rendering: camera.position.set(getPlayer().getPosition().x,

Why doesn't SpriteBatch draw anything (LibGdx)?

白昼怎懂夜的黑 提交于 2020-01-25 04:21:25
问题 This is from day 6 of the flappy bird recreation tutorial -http://www.kilobolt.com/day-6-adding-graphics---welcome-to-the-necropolis.html Here is the image file i am using for texture in my game. It is a 256px x 64px .png file. Here is the class that I used for loading the texture and the specific TextureRegion(part of the texure) that I want the SpriteBatch to draw. public class AssetLoader { public static Texture texture; public static TextureRegion bg; public static void load() { texture =

Strange libgdx TextField ui render error (IndexOutOfBoundsException)

允我心安 提交于 2020-01-25 04:11:27
问题 I get this error just once in a while when libgdx ui renders: 09-25 17:50:26.779 31171-32670/se.company.app.android E/AndroidRuntime﹕ FATAL EXCEPTION: GLThread 1126 Process: se.company.app.android, PID: 31171 java.lang.IndexOutOfBoundsException: index can't be >= size: 36 >= 36 at com.badlogic.gdx.utils.FloatArray.get(FloatArray.java:104) at com.badlogic.gdx.scenes.scene2d.ui.TextField.calculateOffsets(TextField.java:214) at com.badlogic.gdx.scenes.scene2d.ui.TextArea.calculateOffsets

Libgdx AssetsManager - Sounds Loaded but “Not Loaded Error”?

淺唱寂寞╮ 提交于 2020-01-25 03:41:08
问题 When using LibGDX's AssetsManager, I've implement an AssetsManager for managing Sounds, and made it global. The files are all located within ../data/sounds/.* (example: ../data/sounds/buttons/buttonl.mp3) Then I load sound files into the manager, and then include some code to play those sounds. Code below: public final class Sounds { private static HashMap<String, HashMap<String, String>> entries = new HashMap<String, HashMap<String, String>>(); private static HashMap<String, String>

Need an analog for “inline block” from CSS in scene2d.ui

假如想象 提交于 2020-01-24 14:07:24
问题 Is there a way to create a widget like Morrowind's items list using scene2d.ui? That is, a container where you can put fixed-sized elements and they would stack up in a row (or in a column) until they fill the parent container by width/height, so after that they'd stack up in the next row/column? In the image you can see scrolling, but I'd still accept an answer that doesn't allow scrolling. Also I'm aware that inline block elements in CSS don't stack vertically (like they do in Morrowind),

Can't draw a ninepatch image and stage at the same time

本小妞迷上赌 提交于 2020-01-24 13:19:08
问题 Whenever I try to draw a ninepatch image and a stage the last thing that's called is being drawn. I have tried to use a orthographic camera but didn't succeed. What I have tried: batch.setProjectionMatrix(camera.combined); ninePatch.draw(batch, xPos, yPos, width, height); stage.act(delta); stage.draw(); camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); stage.setCamera(camera) EDIT: The code The CreateQuiz class public class CreateQuiz implements Screen{

libgdx SpriteBatch UnsatisfiedLinkError desktop

眉间皱痕 提交于 2020-01-24 02:46:09
问题 I am getting UnsatisfiedLinkError in a LibGdx project, when trying to run a desktop standalone version of it. Note, this problem doesn't occur if I simply run a desktop version directly without building a standalone jar for it, only if I build a desktop jar first, and then try to run that. It is interesting to note that, it was overall a lot easier to run the desktop version directly, and I wasn't even to come close to running a standalone desktop jar until I hunted down a whole bunch of jar

Libgdx polygon triangulation

你。 提交于 2020-01-23 08:05:13
问题 Ok, so I have a polygon (simple but concave) that I'm trying to cut into triangles to make it collide with an other polygon. I knew my polygone was concave, so i decided to use LibGDX EarClippingTriangulator to manage to cut it into triangles. So, with this code, I get my triangles vertices : public void triangulate() { Vector<float[]> trianglesVertices = new Vector<float[]>(); ShortArray pointsCoords = new ShortArray(); EarClippingTriangulator triangulator = new EarClippingTriangulator(); //

scene2d button scaling with libgdx

杀马特。学长 韩版系。学妹 提交于 2020-01-22 20:50:07
问题 I don't know if it is just me, but drawables confuse me. Are they intended to keep the size they are given, or is there a way to scale the image within them? I understand they can use ninepatch to fill certain areas by stretching an image, but I want to scale the image that it stretches. I am using a TextButton for my menu buttons, but they are way too big, and I would love to know how to scale them. I am retrieving the skin from an atlas, which has ninepatch images in it. Here is the