libgdx

libgdx - junit testing - how do I communicate with the Application thread?

删除回忆录丶 提交于 2019-12-12 03:18:55
问题 I am trying to do junit testing on a libgdx game, and have found this thread to be very helpful: Unit-testing of libgdx-using classes I have a test class similar to the following: public class BoardTest { private static Chess game; private static HeadlessApplication app; @BeforeClass public static void testStartGame() { game = new Chess(); final HeadlessApplicationConfiguration config = new HeadlessApplicationConfiguration(); config.renderInterval = 1f/60; // Likely want 1f/60 for 60 fps app

libgdx actor touchHandling

拈花ヽ惹草 提交于 2019-12-12 02:55:18
问题 I am currently experience some funny issue with touchHandling on LibGdx . My code is as follows:- testCount=0; ThisButton.addListener(new InputListener() { public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { testCount++; gameLog("touchDown - testCount: " + testCount); return true; } public void touchUp (InputEvent event, float x, float y, int pointer, int button) { testCount++; gameLog("touchUp - testCount: " + testCount); } }); Theoretically, testCount

Dragging in libgdx on SpriteBatch

六眼飞鱼酱① 提交于 2019-12-12 02:53:41
问题 I am making a game where I have to drag objects of a Screen. I am making Screen objects using SpriteBatch.draw(....) method where I am using rotation so using only one Texture Region. I have to implement drag on object but I am unable to start the dragging part. 回答1: package com.dance.utils; import com.badlogic.gdx.input.GestureDetector; import com.badlogic.gdx.input.GestureDetector.GestureListener; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; import com.dance

Parallax background tiled imperfectly

梦想的初衷 提交于 2019-12-12 02:47:38
问题 I have some problems with my parallax background images. I embedded a GIF below that shows the problems: (1) there's a black flickering line at the edge of the texture and (2) the movement is not smooth (and this isn't due to the GIF's small frame rate). I also added the short code for my ScrollableImage class, which is at the heart of how I implemented parallax. I suspected the problem might be due to the modulo operation inside the setScrollOffset method, but that wasn't it and now I'm out

Libgdx - Converting 2D map coords to 3D space coords

家住魔仙堡 提交于 2019-12-12 02:45:56
问题 I have an object moving about in a flat 2D coordinate system (0-1000,0-1000). In a 3D space coordinate system, I have a sphere and a camera looking at the sphere. I then want to convert these 2D coordinates to the 3D world/space coordinates and then move this object around the surface of the sphere. So, it's basically like converting Lat/Long into a 3D spacial coordinate. Currently I'm using setFromSpherical() but maybe I'm using it the wrong way. Vector3 my3DVector = new Vector3(0,0,0);

LibGDX File not found

无人久伴 提交于 2019-12-12 02:45:49
问题 Im trying to load a tiled map in libGDX with tileMap = new TmxMapLoader().load("maps/level1.tmx"); but somehow it returns a File not found exception: Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: maps\level1.tmx (Internal) at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136) at com.badlogic.gdx.files.FileHandle.reader(FileHandle.java:164) at com.badlogic.gdx.utils.XmlReader.parse(XmlReader.java:81) ... 9 more I already tried to change the path to "/maps

Move a character randomly with time

人走茶凉 提交于 2019-12-12 02:37:48
问题 I'm trying to do a game with libgdx like "Cache-cache game" I want for my character to stay 2 seconds in the first place and to give each 2 seconds a new Random place, i.e a new element of the array carte . First, I have generate my random index and the character stay in the first place. My problem is : How should I make that each keyboard input makes my character move in a random place in the array? This is my code: hi everybody i'm trying to do a game with libgdx like "Cache-cache game" i

Libgdx and Box2D Draw a custom shape

时间秒杀一切 提交于 2019-12-12 02:10:11
问题 I have the following shape: http://s16.postimg.org/sfhb5wgdx/slime.png and I want to draw it in LibGDx just like that because am using Box2d wand will be used in collisions. I have heard I can used a mesh to create this but there isn't much documentation about drawing anything from an image. Do I seriously have to define all the points myself? Is there a better way to extract a shape from in image? 回答1: Use Physics body editor https://code.google.com/p/box2d-editor/ this will solve your

Libgdx, how can I create a rectangle from coordinates?

◇◆丶佛笑我妖孽 提交于 2019-12-12 02:06:38
问题 I am currently trying to make a selector box for an RTS game. For this I need to be able to drag the mouse in order to create the selection box, however this can lead to a negative length/width. In Libgdx is there a way to make rectangle from just using 2 sets of coordinates? Thanks. 回答1: this is a simple idea, if I understand what you want to do: to create a rectangle you can use this, Rectangle(float x, float y, float width, float height) for more inforamacion you can read it here http:/

Contact Listener not working in Libgdx

痞子三分冷 提交于 2019-12-12 01:55:22
问题 I am developing a game in Libgdx and I am working on collision detection between two bodies in box 2D. I used "Contact Listener" to detect collision but nothing happens when the bodies collide. This is my code public Player(World world,float x,float y,float width) { this.width=width; //IMP height=width*2; BodyDef polygon=new BodyDef(); polygon.type=BodyType.DynamicBody; polygon.position.set(x,y); // polygon.fixedRotation=true; PolygonShape poly =new PolygonShape(); poly.setAsBox(width/2