libgdx

LIBGDX making 5 different buttons on one screen

三世轮回 提交于 2019-12-11 09:20:03
问题 I have 5 buttons i need to make do different things but they don't and i need to know how to make them do it. Here is my code; public class MainMenu implements Screen { CrazyZombies game; Stage stage; TextureAtlas atlas; Skin skin; SpriteBatch batch; Button play, option, quit, custom, store, menu; public MainMenu(CrazyZombies game) { this.game = game; } public void create () { stage = new Stage(); } @Override public void render(float delta) { Gdx.gl.glClearColor(0.09f, 0.28f, 0.2f, 1); Gdx.gl

setAngularVelocity rotates really slowly

感情迁移 提交于 2019-12-11 09:16:46
问题 I am using the basic libgdx box2d to manage physics operations of a game. Everything is working properly, except the rotations: even when I set anyobject.body.setAngularVelocity(someLargeConstant); the object rotates really slowly(and almost at the same speed) no matter what the 'someLargeConstant' is. Except when I use small numbers for parameter, it can rotate slower. Thus I think I somehow have a maximum angular velocity constant inside my world object, which should be set to some small

LibGdx - Dispose Sprite or Texture in Sprite is mandatory?

我的梦境 提交于 2019-12-11 09:03:48
问题 I am loading my sprite with the texture from my assets like I have mentioned below. gameBoardSprite = new Sprite( new Texture(Gdx.files.internal("data/gameboard.png"))); Do I need to have the below dispose in my code ? Is it mandatory ? gameBoardSprite.getTexture().dispose(); 回答1: Yes, dispose must be called on any Disposable object before you lose your reference to it or there will be a memory leak. The VM won't automatically dispose of the native memory used by OpenGL objects like Textures

Dagger and libgdx

懵懂的女人 提交于 2019-12-11 08:57:30
问题 Is it possible to use dagger 2 and libgdx web? The libgdx project builds fine with android and desktop. When I add a web module and run with ./gradlew html:superDev [ERROR] Line 1: The type javax.inject.Named cannot be resolved. It is indirectly referenced from required .class files [ERROR] Line 30: The import dagger.Lazy cannot be resolved [ERROR] Line 32: The import javax.inject.Inject cannot be resolved [ERROR] Line 37: Inject cannot be resolved to a type After following this http://www.g

Box2DDebugRenderer and SpriteBatch misplaced

别等时光非礼了梦想. 提交于 2019-12-11 08:37:39
问题 I am playing with libgdx for making yet another physics game :) and I have found something weird. Namely I use SpriteBatch for rendering images at the same time with Box2DDebugRenderer for debuging. But when the physics acts, they appear to be misplaced. I wrote: public class Canon implements ApplicationListener { private OrthographicCamera camera; private Box2DDebugRenderer debugRenderer; /... public void create() { camera = new OrthographicCamera(CAMERA_WIDTH, CAMERA_HEIGHT); world = new

glsl shader - color blend, normal mode (like in Photoshop)

孤街浪徒 提交于 2019-12-11 08:35:40
问题 Im trying to create effect of blending 2 colors (actually image and color as overlay over image), like in photoshop "Color Overlay" with "Normal Blending" mode Im using libgdx This is what i have so far attribute vec4 a_position; attribute vec4 a_color; attribute vec2 a_texCoord0; uniform mat4 u_projTrans; varying vec4 v_color; varying vec2 v_texCoords; void main() { v_color = a_color; v_texCoords = a_texCoord0; gl_Position = u_projTrans * a_position; } And fragment #ifdef GL_ES #define LOWP

Hello world, libgdx crashes on phone

时间秒杀一切 提交于 2019-12-11 08:16:14
问题 I am trying to get into android development, after some reading i have settled on libgdx as the engine i will use. I have got all the tools installed so i go to the wiki and find a Hello world tutorial! http://code.google.com/p/libgdx/wiki/HelloWorld I then download the zip and run gdx-helloworld it works! - GREAT. So i then decide to see if it runs on my phone (Galaxy note, custom rom, android 2.3.6)... run gdx-helloworld-android it gets onto the phone but instantly crashes. Is this to be

Java LibGDX Multi Touch Movement

非 Y 不嫁゛ 提交于 2019-12-11 08:13:08
问题 What is the problem? I am using this code to movement for two players. But it is not working. Player1 is more quick than player2. How can I fix? for (byte i = 0; i < 20; i++) {maxDistance = 10 * Gdx.graphics.getDeltaTi me(); if (Gdx.input.isTouched(i) && Gdx.input.getY()<= 400) { player1TouchPosition.set(Gdx.input.getX(i), Gdx.input.getY(i), 0); camera.unproject(player1TouchPosition); } player1Tmp.set(player1TouchPosition.x, player1TouchPosition.y).sub(player1Rectangle.x, player1Rectangle.y);

LibGDX Stop body from taking properties of previously deleted body

淺唱寂寞╮ 提交于 2019-12-11 07:57:23
问题 VIDEO FOR CLARITY: https://www.youtube.com/watch?v=3Mrro8sjcqo#t=25 I'm making my first LibGDX game, and I'm having trouble destroying and creating bodies. I've been using this snippet (because it seems to be everywhere) to remove bodies: private void sweepDeadBodies() { for (Iterator<Body> iter = tmpBodies.iterator(); iter.hasNext();) { Body body = iter.next(); if (body != null) { Entity data = (Entity) body.getUserData(); //Just the bodies data if (data.isFlaggedForDelete) { iter.remove();

My AdMob banner is not showing

浪子不回头ぞ 提交于 2019-12-11 07:56:20
问题 So, I have LibGDX app and I'm adding banner like this: public class AndroidLauncher extends AndroidApplication { @Override protected void onCreate (Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create the layout RelativeLayout layout = new RelativeLayout(this); // Do the stuff that initialize() would do for you requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);