libgdx

How can I do something every second? [LibGDX]

岁酱吖の 提交于 2019-11-30 07:18:28
Lets say I want to make a loop or something that prints out, for example, "Mario" every second. How can I do this? Can't seem to find any good tutorials that teach this anywhere =P You can use java.util.Timer. new Timer().scheduleAtFixedRate(task, after, interval); task is the method you want to execute, after is the amount of time till the first execution and interval is the time between executions of aforementioned task. As @BennX said you can sum up the delta time you have in your render method or get it by calling Gdx.graphics.getDeltaTime(); . If it is bigger then 1 ( delta is a float ,

slow model batch rendering in libGDX

萝らか妹 提交于 2019-11-30 06:52:11
I've got a question whether there is a special mode for grouping models in libGDX. I created a simple class that implements ApplicationListener which shows my problem. I am using the nightly build of libGDX. I read two different models which use the same texture. The application renders respectively 250 models of every type. This is how the part of rendering code looks like: mModelBatch.begin(camera); for(int y=0; y<50; y++) { for(int x=-5; x<5; x++) { ModelInstance instance; if(x%2 == 0) instance = modelInstance1; else instance = modelInstance2; instance.transform.setToTranslation(x, 0, -y);

Error:(2, 0) Plugin with id 'jetty' not found

血红的双手。 提交于 2019-11-30 06:41:29
Yesterday I upgraded Android Studio to version 3.0, but I'm working with LibGdx and after the upgrade I cannot build my project. When I'm try to build, it gives me an error: Error:(2, 0) Plugin with id 'jetty' not found How should I fix this? Currently html module using deprecated jetty plugin which is removed in Gradle 4.1 version. Android Studio 3.0 using Gradle-4.1 and android-gradle-plugin:3.0.0 Gradle 4.1 is not supported yet in LibGDX, there is an issue for the same, which is now upgraded for Gradle 4.6 If you still want to use Android Studio 3.0 Downgrade Gradle to 3.3 from 4.1 Find

Switching between screens Libgdx

寵の児 提交于 2019-11-30 05:34:48
Hey everyone I am still working on this libgdx project and I am trying to figure out the best way to change the screens to my game screen Now, when a button is clicked I need it to transition to the game screen. I have seen a few implementations extending the game class but I am not sure what the best approach from here is. If you see some code that could be improved please let me know. Here is the main application class: public class ConnectFourApplication implements ApplicationListener { private Screen screen; public static void main(String[] args) { new LwjglApplication(new

Split-Screen in LibGDX

亡梦爱人 提交于 2019-11-30 05:18:06
This question is short and simple. How do I create a split screen effect in LibGDX. If I create two cameras all it will do is draw one located somewhere and then draw the next, overwriting the previous camera. I then thought to use multiple screens but that doesn't look like it will work as it only supports resizing and not relocating within the window. I'm also using Box2DDebugRenderer as well as a ShapeRenderer so it would also need to cut those off at the split-screen limit. There doesn't seem to be any documentation on the LibGDX site. After asking around a bit on the #libgdx IRC, the

Producing eraser effects using libgdx and OpenGL ES

谁都会走 提交于 2019-11-30 05:06:35
Please consider the following images for the illustration: Initially I fill the whole screen/stage with individual Images until the screen turns pink. Each blob of pink colour is an individual Image actor that I add to the stage. Now I want to implement the touchDown method in such a way that each time the user touches the screen, it erases a part of that Image where the touch event took place. However, that touch event should not effect other Images/actors/TextureRegions that are behind or above the pink blob actors. How am I supposed to achieve this in libgdx using OpenGL ES? Please help me

AssetManager in LibGDX

旧巷老猫 提交于 2019-11-30 04:59:34
问题 I am trying to use the AssetManager class in LibGDX and I understand how it works but I am trying to implement a loading screen. I have followed the AssetManagerTest.java file here, but I am having a hard time trying to figure out how to get it to work correctly. Can someone point me in the right direction? My goal is to load the assets (textures, sounds, fonts, ... etc) and update a bar with the percentage complete on the screen. I don't understand the ResolutionFileResolver and the

Draw a BitmapFont rotated in libgdx

∥☆過路亽.° 提交于 2019-11-30 04:03:36
问题 I can't seem to figure out how to rotate a Bitmap font correctly. I think you modify the transformation matrix of the SpriteBatch. However, trying to rotate that rotates the text around some point, and I don't know how to rotate it relative to the text itself. 回答1: you can try the following code: Matrix4 mx4Font = new Matrix4(); BitmapFont font; SpriteBatch spriteFont; font = new BitmapFont(Gdx.files.internal("data/font/agencyFB.fnt"), Gdx.files.internal("data/font/agencyFB.png"), true); /

libgdx ClassNotFoundException when starting Desktop main - Mac, IntelliJ

二次信任 提交于 2019-11-30 03:56:57
问题 I set up my project as described in the IntelliJ setup tutorial, but I am unable to start the Desktop application. The android app starts up fine in both the emulator and on my S3, but main in Desktop is unable to find my class.. Logs: Exception in thread "main" java.lang.ClassNotFoundException: com.xxx.xxx.xxx.DesktopStarter at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass

libgdx: Rotate a texture when drawing it with spritebatch

允我心安 提交于 2019-11-30 03:48:23
Im trying to rotate textures when I draw them. I figured it would make more sense to do this than to rotate the images 90 degrees in paint.net and save them in different files. I looked thought the api documentation for spritebatch drawing arguments but I just dont understand. There are a bunch of arguments such as srcX, srcY, originX and so on. Also i would like to know how to do the same for texture regions. Heres a link to the api documentation page: http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/SpriteBatch.html Thank you! again from the documentation ,