libgdx

Using LibGDX, how do you have an animation using seperate images ?

这一生的挚爱 提交于 2019-11-27 06:30:48
问题 I'm learning how to make games using LibGDX and I'm trying to make a small platform game (using Eclipse). I made 4 images on the main character running to make an animation when he moves. However, I can't find anything online to show me how to make an animation without using a SpriteSheet. How do you make an animation using 4 different images ? 回答1: First of all: You should not use different images. Maybe for your player it does not matter much (because there is only one) but in general you

How do libgdx detect keyboard presence

你说的曾经没有我的故事 提交于 2019-11-27 03:29:10
问题 When writing in the Textfield, I need my textfield to move upwards in order to let the textfield be visible when the keyboard pops up. Does libgdx have some kind of method which returns true if the keyboard is visible and false when it is down? 回答1: The following code will detect when you press a textfield, prevent it from showing the keyboard and then open a native dialog that moves up and down with the keyboard. It will take the input from the native dialog and finally put it back in your

How to render Android's YUV-NV21 camera image on the background in libgdx with OpenGLES 2.0 in real-time?

橙三吉。 提交于 2019-11-27 02:53:13
Unlike Android, I'm relatively new to GL/libgdx. The task I need to solve, namely rendering the Android camera's YUV-NV21 preview image to the screen background inside libgdx in real time is multi-faceted. Here are the main concerns: Android camera's preview image is only guaranteed to be in the YUV-NV21 space (and in the similar YV12 space where U and V channels are not interleaved but grouped). Assuming that most modern devices will provide implicit RGB conversion is VERY wrong, e.g the newest Samsung Note 10.1 2014 version only provides the YUV formats. Since nothing can be drawn to the

Libgdx light without box2d

蹲街弑〆低调 提交于 2019-11-27 02:53:03
问题 I just started creating a game using libgdx. It is a top down 2d shooter using scene2d ui. Now i thought, that i could add darkness and light to some levels, but i don't want to rewrite everything using box2d. I don't need realistic shadows just some kind of ambient light and a lightcircle arround my character, which is not affected by walls and other obstacles arround him. So i wanted to know if there is any kind of lightsystem in libgdx? Or can i use box2dlights without using box2d bodies

How to deal with different aspect ratios in libGDX?

时光总嘲笑我的痴心妄想 提交于 2019-11-27 02:41:50
I have implemented some screens using libGDX that would obviously use the Screen class provided by the libGDX framework. However, the implementation for these screens works only with pre-defined screen sizes. For example, if the sprite was meant for a 640 x 480 size screen (4:3 Aspect ratio), it won't work as intended on other screen sizes because the sprites go par the screen boundaries and are not scaled to the screen size at all. Moreover, if simple scaling would have been provided by the libGDX, the issue I am facing would have still been there because that would cause the aspect ratio of

why game is running slow in libgdx?

别等时光非礼了梦想. 提交于 2019-11-27 02:01:07
问题 I am making racing game in Libgdx.My game apk size is 9.92 mb and I am using four texture packer of total size is 9.92 Mb. My game is running on desktop but its run on android device very slow. What is reason behind it? 回答1: There are few loopholes which we neglect while programming. Desktop processors are way more powerful so the game may run smoothly on Desktop but may slow on mobile Device. Here are some key notes which you should follow for optimum game flow: No I/O operations in render

When to use actors in libgdx? What are cons and pros?

自作多情 提交于 2019-11-27 00:23:08
问题 I'm writing simple solar system simulator. This is my first libgdx project. I'm using a Stage and Actors for the main menu and is pretty handy especially touch events handling. But ... looking at the examples i see nobody uses actors in actual game logic. I wander if i should use actor as a parent of planet class or just write my own class tor that. The planets won't be touchable and they will be moved only between the frames so the third parameter of action MoveBy will have to be time

In libgdx, how do I get input from the back button?

风流意气都作罢 提交于 2019-11-27 00:20:48
问题 For my game, I'd like the Android back button to take you to the pause menu, instead of minimizing the game. From what I've googled, I know I need to call Gdx.input.setCatchBackKey(true); But how do I actually check for the button press? input.isKeyDown(Keys.BACK) doesn't seem to do anything. 回答1: I solved the problem like this: public class MyApplication implements ApplicationListener, InputProcessor { // !! Remember to override all other required methods !! ... @Override public void create(

Changing the Coordinate System in LibGDX (Java)

那年仲夏 提交于 2019-11-27 00:08:49
LibGDX has a coordinate system where (0,0) is at the bottom-left. (like this image: http://i.stack.imgur.com/jVrJ0.png ) This has me beating my head against a wall, mainly because I'm porting a game I had already made with the usual coordinate system (where 0,0 is in the Top Left Corner). My question: Is there any simple way of changing this coordinate system? If you use a Camera (which you should) changing the coordinate system is pretty simple: camera= new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); camera.setToOrtho(true, Gdx.graphics.getWidth(), Gdx.graphics

libgdx SpriteBatch render to texture

我的未来我决定 提交于 2019-11-26 23:58:36
Is it possible to render to texture using SpriteBatch in libGdx (Java engine for Android/Desktop)? If so, how do it? Basically I want to render everything to 320 x 240 region of 512 x 256 texture and than scale region to fit screen (in landscape mode). This way I want to eliminate artifacts which happen when I scale alpha blended textures independently. If there is any other way to remove such artifacts, please point them out :) And is there any online documentation for libGdx? PiotrK This snippet was given to me on the LibGDX forum and it works flawlessly. private float m_fboScaler = 1.5f;