libgdx

how do i fix this array issue?

夙愿已清 提交于 2019-12-13 00:26:57
问题 lemme try to explain whats happening now: when I place 3 "X's" next to each other I simply want to remove them, but its only happening part of the time, sometimes it removes all of them, and other times it removes just 1 or just 2 of them. The blocks are instances of the Block class being put in an arraylist.... Furthermore for a wider understanding: I'll randomly place blocks all over the grid and try to fill it, sometimes as im adding the blocks to the grid other blocks start disappearing.

How to make a sprite point somewhere?

你。 提交于 2019-12-13 00:25:13
问题 I wan't my sprite to point at the cursor, how do I compute on how much do I need to rotate it? //First is get the cursor position x=Gdx.input.getX(); y=Gdx.input.getY(); //then rotate the sprite and make it point where the cursor is Sprite.rotate(??); update--> I tried this but I don't know what should be the condition to make it stop rotating when is already pointed at the right direction double radians = Math.atan2(mouseY - spriteY, mouseX - spriteX) float fl=(float)radians; Sprite.rotate

How to rotate a pixmap by 90º to draw to a texture in libgdx?

╄→гoц情女王★ 提交于 2019-12-12 20:17:29
问题 I need to rotate a Pixmap by 90 degrees. I have seen an answer that achieves a flipped Pixmap. I need to rotate images that are in portrait orientation to landscape already on the Pixmap-level to later create textures out of them. 回答1: similar to the flip pixmap method I achieved a 90º rotated Pixmap like this: private Pixmap rotatePixmap (Pixmap srcPix){ final int width = srcPix.getWidth(); final int height = srcPix.getHeight(); Pixmap rotatedPix = new Pixmap(height, width, srcPix.getFormat(

Android libgdx prefs getting lost

早过忘川 提交于 2019-12-12 19:24:24
问题 I've created Android game in Libgdx engine... After some time I've noticed that game options that I'm saving into prefs are lost after killing the app in some app killer, or if I do "Force Close" in Android Settings... Is there a way to prevent this? I've never done "Clear Data", just "Force close"... Is there a good alternative to prefs? Really weird problem... This is how I get and put values into prefs... /** Shared preferences */ public static final Preferences prefs = Gdx.app

Error when I try to generate a libgdx projet

白昼怎懂夜的黑 提交于 2019-12-12 17:27:24
问题 I'm trying to do a project on android studio with libgdx but I have a problem when I generate a libgdx project. At first, he told me that my local variable JAVA_HOME had a problem and he could findn't my JDK (that was present) When I tried to copy my java JDK on my file "c:\dev\java\JDK", he told me : Generating app in C:\Users\Thomas\Desktop\YoloRPG Executing 'C:\Users\Thomas\Desktop\YoloRPG/gradlew.bat clean --no-daemon' Unzipping C:\Users\Thomas\.gradle\wrapper\dists\gradle-2.10- all

How to create and use very large palette textures for use in opengl?

被刻印的时光 ゝ 提交于 2019-12-12 17:25:42
问题 Details: I have a glsl fragment shader with a uniform texture, "u_MapTexture" with several thousand colors on it (max of about 10k-15k unique rgb values). I also have a uniform palette texture ("u_paletteTexture") that is 16384 × 1 that I want to use to index the colors on u_MapTexture to. My problem is that no matter what I try mathematically, I can't seem to properly index the colors from the first texture to the palette texture using the RGB values of the passed color. Amy thoughts or

Libgdx - How to pass a variable value from one screen to another?

走远了吗. 提交于 2019-12-12 16:23:49
问题 I'm creating a game for Android phones and I need a player number from screen where I select it to another screen where I use it for something else. On screen where I select specific number, method for returning number of players works perfectly but when I use that method on another screen it returns zero. I select number (picture for specific number) from ScrollPane. When I change screen I clear screen and draw new one as usual. So my question is how can I save that value and return it even

Libgdx shader setup NullPointerException

偶尔善良 提交于 2019-12-12 14:49:50
问题 I try to setup my shader like this: fog = new ShaderProgram(Gdx.files.local("shader/shad.vert"), Gdx.files.local("shader/shad.frag")); But it gives me this exception: Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NullPointerException at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:113) Caused by: java.lang.NullPointerException at com.badlogic.gdx.graphics.glutils.ShaderProgram.loadShader(ShaderProgram.java:194) at

Cannot load progressive jpeg images in libgdx

久未见 提交于 2019-12-12 14:07:46
问题 Here's my source package com.effect.bio; import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.graphics.GL10; import com.badlogic.gdx.graphics.Mesh; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.maps.tiled.TiledMap; import com.badlogic.gdx.maps.tiled

Best way to load big background in libgdx

浪尽此生 提交于 2019-12-12 14:02:45
问题 I am developing a game using libgdx. Now i'd like to have a Background all over my map (Map size is not fixed yet i'll decide later). My map is tile based but i don't use TiledMaps. So i create and load the map with own code/editor. My question now: How should i implement the background thing? I thought about different ways: Loading a huge Image, which covers all the map. This is not realy good cause i render things, which are not in my viewport (80 Tiles X,50 Tiles Y) . Deviding the Image in