libgdx

Why Libgdx's Table does not accept scale action?

送分小仙女□ 提交于 2020-01-03 08:54:09
问题 I'm using scene2d in libgdx library for creating some UI in my game. I used a Table and I want to take some scaling action when user touches to make a button touching sense. When I used any other "Actor" types like Group and giving it a scale action it works but not Table. this is my Table definition: Table table = new Table(); table.setSize(width, height); table.setPosition(x, y); table.setOrigin(width/2, height/2); table.add(new Label(...)); table.row(); ... And in my touchDown event I give

How can i find the height of soft-keyboard in a LibGDX application

谁说我不能喝 提交于 2020-01-03 07:22:07
问题 I'm developing an Android game with LibGDX . And I need to find the height of the soft-keyboard the user is using, as I want to display some objects right above the keyboard. I have read this thread: how can i get soft keyboard height on android? But the comment suggests that it doesn't work, and it also seems to be for using with Android SDK . I'm not sure. Does anyone know a way that will definitely work? 回答1: If your problem is that your textfields are obscured then I suggest using void

Fragment shader: No uniform with name in shader

£可爱£侵袭症+ 提交于 2020-01-03 05:09:06
问题 I have problem with fragment shader in libgdx. Below is my fragment shader. #ifdef GL_ES precision mediump float; #endif uniform float u_aspectRatio; varying vec2 v_texCoords; uniform sampler2D u_texture; void main() { gl_FragColor = texture2D(u_texture, v_texCoords); } In program I do shader.setUniformi("u_texture", 0); // work fine shader.setUniformf("u_aspectRatio", 0.0f); //no uniform with name 'u_aspectRatio' in shader shader.isCompiled() return true and first set work fine, but in

Sprite flicker while moving libgdx

别来无恙 提交于 2020-01-03 05:08:49
问题 This code makes image Border flicker(Flash) while moving left,right,down or up. Why image border flash wile moving even if I use Screen class render() method delta value. package com.me.mygdxgame; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.graphics.GL10; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture.TextureFilter;

Non-continuous Rendering in Loading screen not working as it supposed to work - Multithreading LIBGDX

♀尐吖头ヾ 提交于 2020-01-03 03:12:04
问题 I'm using Non-continuous Rendering in my loading screen so I can update it as I INIT different parts of my code in a secondary thread. That way I can manually increase the Animation counter that I use to draw a Sprite which shows a filling hourglass in tune with the loading of my assets. So, I load my game screen with the help of another thread (atlases, textures, init variables,etc) : Runnable load_game_screen = new Runnable(){ public void run(){ new_game_screen.load_all(); } }}; Thread

libgdx Timer countdown implmentation

我的未来我决定 提交于 2020-01-03 02:25:11
问题 I want to create efficienty timer in LibGDX framework, that will count the time left for my character. The doSmth() method should be called as many times as some flag is set to true. I know that the third parametr of Timer is that, how many times should it trigger. For now one Im calling the method recursive, but I dont think it is the efficient way. public void updateTimer(){ new Timer().scheduleTask(new Timer.Task() { @Override public void run() { doSmth(); updateTimer(); } },1); } 回答1: It

Is it possible to skew actor in libgdx

ε祈祈猫儿з 提交于 2020-01-02 15:25:24
问题 Is it possible to skew/shear actor (image) in libgdx ? I have found that skew is possible for sprites, as discussed here What about an actor? 回答1: this worked for me: class SkewActor extends Actor { private TextureRegion tex; private Affine2 affine = new Affine2(); public SkewActor(TextureRegion textureRegion) { this.tex = textureRegion; } @Override public void draw(Batch batch, float parentAlpha) { Color color = getColor(); batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);

Collision detection between a BoundingBox and a Sphere in libgdx

南楼画角 提交于 2020-01-02 09:58:40
问题 In my libgdx game I have 3D BoundingBoxes and Spheres for map and player objects. I want to calculate whether they collide with each other in order to properly simulate the motion of these objects. What method can I use to calculate whether these objects collide/intersect? 回答1: You can use the following method: public static boolean intersectsWith(BoundingBox boundingBox, Sphere sphere) { float dmin = 0; Vector3 center = sphere.center; Vector3 bmin = boundingBox.getMin(); Vector3 bmax =

How can I add button to top right corner of a Dialog In libgdx?

蓝咒 提交于 2020-01-02 09:54:00
问题 I want to add close button to top right corner of a dialog box. I tried using setbounds with addactor and just add and setposition with setsize and addactor, but nothing works. I know that dialog works with table layout, it has a table for content and for buttons. I don't want to use this layout and put the button outside this layout like on the border of the dialog. How can I do it? This is how it should be: 回答1: The easiest solution I could come up with now, is to use negative padding for

How can I add button to top right corner of a Dialog In libgdx?

亡梦爱人 提交于 2020-01-02 09:53:39
问题 I want to add close button to top right corner of a dialog box. I tried using setbounds with addactor and just add and setposition with setsize and addactor, but nothing works. I know that dialog works with table layout, it has a table for content and for buttons. I don't want to use this layout and put the button outside this layout like on the border of the dialog. How can I do it? This is how it should be: 回答1: The easiest solution I could come up with now, is to use negative padding for