libgdx

Multiple fixtures on one body or multiple bodies?

梦想的初衷 提交于 2019-11-30 02:57:20
问题 Let's say I wanted to create 1000, or maybe even 5000 static body lines on the screen. What I am wondering is, what is the difference between attaching all of these lines (fixtures) onto a single body, or placing each fixture onto its own body. Is there a performance difference between the two methods, or does one method provide more functionality or control over the other method? Below shows the difference between both methods. Attaching each line onto a single body: // Create our body

How to make a smooth camera follow algorithm?

大城市里の小女人 提交于 2019-11-30 01:47:58
I am making a game with LibGDX (Java). I need the camera to follow a fast moving character. The easiest way to do it is to just write this: this.getCamera().position.set(obj.x, obj.y, 0); But, is there any algorithm to make this more smooth? Like when camera is not that strict, and is always a bit late: character goes quick right, camera follows with slight delay, or if you suddenly appeared somewhere far, camera doesn't teleport instantly but travels at a top speed to you when it comes closer it slows down a bit and finds you again. Is there any libgdx libs that do that or anyone had this

libgdx-android: Intercepting back key and confirm exit

拜拜、爱过 提交于 2019-11-30 01:15:55
问题 Using libgdx, how can I intercept the android BACK key in order to do some preprocessing (e.g. asking for confirmation from user), before actually performing the command to exit the game? 回答1: 1. Enable catching of Back Key. In the class that implements ApplicationListener @Override public void create() { ... Gdx.input.setCatchBackKey(true); ... } 2. Handle catching of Back Key. In a class that implements the InputProcessor @Override public boolean keyDown(int keycode) { ... if(keycode ==

(when adding jar) - Module “android” must not contain source root

对着背影说爱祢 提交于 2019-11-30 00:00:52
I'm trying to add gdx-tools.jar to a libGDX project in IntelliJ. The result: Module "android" must not contain source root ".../android/src". The root already belongs to module "android". This is what I've tried: project structure > libraries > new project library > java > select "gdx-tools.jar" >select module "desktop" project structure > modules > select "desktop" > new > jars or directories > select "gdx-tools.jar" > Ideas? Just by going to the Artifacts Settings, Modules, Sources tab, and you will see 2 folders called "gen" and "gen[generated]", delete "gen" by clicking on the X icon to

Limit FPS in Libgdx game with Thread.sleep() doesn't work

南楼画角 提交于 2019-11-29 23:45:13
问题 I am developing a little game for android with libgdx and want to limit the fps to 30 to save battery. The problem is that it doesn't work. The fps just drops from 60 to 56. Here is the part of the code: (it's at the end of the render part) System.out.print("\nFPS: " + Gdx.graphics.getFramesPerSecond() + "\n"); if(Gdx.graphics.getDeltaTime() < 1f/30f) { System.out.print("DeltaTime: " + Gdx.graphics.getDeltaTime() + " s\n"); float sleep = (1f/30f-Gdx.graphics.getDeltaTime())*1000; System.out

Libgdx could not determine java version 11.0.1

左心房为你撑大大i 提交于 2019-11-29 21:56:45
问题 I tried everything I installed every possible Java file a million times I installed the newest gradle version but it continues to show this error. I'm on Mac. Please help thanks 回答1: IF you do not want to develop for Android Java 11 works fine libgdx. You have to change some things before everything builds and runs. Here's what I did to get my project working. My context Mac OSX 10.14 and openJDK 11.0.2 , new project, Desktop launcher and a bunch of Extensions (not important). The error you

LIBGDX: What is a “viewport”?

和自甴很熟 提交于 2019-11-29 21:28:32
This post is related to an earlier post of wanting to learn how to properly render in between LIBGDX and Box2D. I had to understand viewport well before I could proceed. After much code/post readings, I felt the meaning of "viewport" was "the rectangle opening of a lens of the camera that views LIBGDX's Game world, where I can move it about the world to view what I want". But, after more reading, I seemed to be nowhere near the actual meaning. I've read the LIBGDX wiki, and read in the OpenGL documentation, which seem to explain viewport as being two different things. LIBGDX Wiki: "The

Use sqlite database for iOS (robovm) with libgdx

此生再无相见时 提交于 2019-11-29 21:06:42
问题 I have a libgdx project (Android) where I use a sqlite database . I'm developing the same project in iOS version (robovm) and I can't find anything about sqlite or database for iOS version. Is it possible to use the same sqlite database ? Thanks. 回答1: I know this is an old thread but this worked for me You dont have to do it EXACTLY like this of course, but this is how i did it First i made a helper class for SQLite called.. SQLiteHelper This would initialize things package com.hamzahrmalik

com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: - Error

人盡茶涼 提交于 2019-11-29 18:13:10
I am trying to develop an application in libGDX for iOS. In my Java class I have written this line private Texture texture = new Texture(Gdx.files.internal("data/folder_name_1/folder_name_2/abcd.png")); and my robovm.xml looks like this- <iosInfoPList>Info.plist.xml</iosInfoPList> <resources> <resource> <directory>../android/assets</directory> <includes> <include>**</include> </includes> <skipPngCrush>true</skipPngCrush> </resource> <resource> <directory>data</directory> </resource> </resources> When I try to run the code on iOS simulator it runs fine. But when I try to run it on an iOS device

Getting AdView to work

我们两清 提交于 2019-11-29 18:05:33
I am developing a game in libgdx. I read the official docs and tried to integrate MobClix Ads in my App but eclipse can't resolve this constructor for ADView class: (for Example): AdView ad = new AdView(this, AdSize.BANNER, "a14d91b10f12454"); This line of code give me an error. Maybe my import is not correct? I import this: import com.google.android.gms.ads.AdSize; import com.google.android.gms.ads.AdView; And the same for: adView.loadAd(new AdRequest()); I tried to search for an answer but I coudn't find, Does somone know how to resolve this? Sorry for my poor english. Put this code to