libgdx

How to scale image according to different screen resolutions in libgdx

家住魔仙堡 提交于 2020-01-05 09:12:00
问题 I am using 480*800 image for my libgdx game. It is running absolutely fine on my smartphone but when i try to run it on high end devices or say tab with resolution 800*1280, it just show the image at one corner of the screen for obvious reasons. I am sure it just needs some camera settings to scale up and down according to the different screen resolutions. Please help me or provide any pointer. 回答1: You can use ViewPort as maintained above or use your own solution, like this: public static

Camera does not follow player

时间秒杀一切 提交于 2020-01-05 08:42:35
问题 I use libgdx have one player which moves in x direction from left to right. Now I want the camera to follow it (like in Flappy Bird for example). What happen is that the player go out off screen when it reaches the right border of screen and the camera don't follow him. I have tried following options but none of them worked: camera.position.set(player.getX(), camera.position.y, 0); camera.position.set(player.getX(), 0, 0); Vector3 vector3= camera.unproject(new Vector3(player.getX(), 0f, 0f));

LIBGDX game configuration with google Play game services Errors

▼魔方 西西 提交于 2020-01-05 08:01:12
问题 I am a starter with Libgdx and Android. I have developed a small game. I have tried following up Google play game services tutorial at https://github.com/TheInvader360/libgdx-gameservices-tutorial using super jumper example. I have also checked every thing on Google developers Documentation.Also I have followed this tutorial http://forum.xda-developers.com/android/apps-games/setting-eclipse-to-google-play-game-t2889796 Plus stack overflow. a. SHA1 key is same when application Is EXPORT from

LIBGDX game configuration with google Play game services Errors

有些话、适合烂在心里 提交于 2020-01-05 08:01:05
问题 I am a starter with Libgdx and Android. I have developed a small game. I have tried following up Google play game services tutorial at https://github.com/TheInvader360/libgdx-gameservices-tutorial using super jumper example. I have also checked every thing on Google developers Documentation.Also I have followed this tutorial http://forum.xda-developers.com/android/apps-games/setting-eclipse-to-google-play-game-t2889796 Plus stack overflow. a. SHA1 key is same when application Is EXPORT from

Libgdx - textures

↘锁芯ラ 提交于 2020-01-05 07:18:14
问题 If I create a texture of .PNG 1024 x 1024 and draw a circle in the middle that is 124 x 124, around it would be empty, does it use the same amount of RAM as if I would draw a circle 124 x 124 on a 124x124 space? I could make all sprites in photoshop on a 1920 x 1080, and lay it out there already and then import all in game at a 0, 0 coordinate and all would lay out perfectly! 回答1: Transparency has nothing to do with RAM usage - it depends on how big in decoded image it means that for picture

font.draw() works correctly on first call but not on second

余生长醉 提交于 2020-01-05 05:27:10
问题 I'm not sure if you're not allowed to call font.draw() twice but the first linedisplays correctly but the second one is very glitchy, a lot of letters are missing [that appear fine in the first line] and random numbers seem to not draw. My .fnt file is fine as it works on buttons and checkbox's just fine. Here's some of my code: private BitmapFont font = new BitmapFont(Gdx.files.internal("test.fnt"),false); private SpriteBatch batch = new SpriteBatch(); //in Render Method batch.begin(); font

font.setColor method not working after libGDX update to latest version

房东的猫 提交于 2020-01-05 04:10:17
问题 I have some 3-4 years old game project in libGDX. Now I decided to update it and to move from Eclipse to Android studio. So, I installed A.S. downloaded and installed fresh libGDX project. Then added my old source files and assets. All went well, with some minor changes game runs. Except font.setColor is not working any more - text on screen is black. Transparency is not working neither. That worked well before. So, my font is generated with Hiero, and it's white (I saw that in some other

Libgdx and Box2DLights - too bright + colors grayed out

…衆ロ難τιáo~ 提交于 2020-01-05 03:05:35
问题 I'm writing a game with LibGDX and Box2DLights for lighting. The first problem is when my lights overlap each other. I have directional light on sun and point light on character. When they overlap output color is way too bright. I tried changing colors of lights but lowering these makes lights useless when there's only one light(too dark). My second problem is the colors are a bit grayed out(see on screen). Image showing my problems - first screen is too bright, second is with only one light

LibGDX GwtApplication Exception (TypeError) in HTML Deployment

╄→尐↘猪︶ㄣ 提交于 2020-01-05 02:47:18
问题 I try to deploy my libgdx game in HTML. In desktop and Android it works well. When I do ./gradlew html:dist , it compile fine and I have a dist folder which is created in html folder. I succeeded to launch the game on a browser: However, when I click on any button which will change the screen, the game crash: The error is : GwtApplication: exception: (TypeError) : a.g[a.b] is undefined (TypeError) : a.g[a.b] is undefined and in the console, I have: Error: java.lang.RuntimeException: com

LIBGDX ScissorStack Example?

北战南征 提交于 2020-01-04 15:57:54
问题 I am looking to create a fog-of-war style effect around on sprite units and was told scissorstack would do the job but I can't figure out what i am doing wrong... I have the typical libgdx set up. I have a class for every Game Character. I would like to control 'how far out' each unit sees by configuring each class. So say I want MainPlayer with fog of war 5, but a Pawn unit to have a fog of war of 1 space around the tile the unit is located in. I have the sprite loaded, tmx map and collision