libgdx

Couldn't load shared library box2d for libgdx

邮差的信 提交于 2020-01-02 06:39:10
问题 I have a libGDX project that is built using maven. It's run fine in the past, but recently, it's stopped working, due to libGDX moving box2d to being an extension. I added the extension as a dependency to the core of my project like I would any other dependency: <dependency> <groupId>com.badlogicgames.gdx</groupId> <artifactId>gdx-box2d</artifactId> <version>${gdx.version}</version> <scope>compile</scope> </dependency> however, when I try to run the project for desktop (or anything else,

What's the right place to dispose a libgdx Screen

荒凉一梦 提交于 2020-01-02 05:45:06
问题 Hello I am working out a game and I wonder how to dispose resources as I am experiencing memory problems. I have something like this: public SplashScreen implements Screen { @Override public void render(float delta) { } @Override public void dispose() { if (batch != null) batch.dispose(); batch = null; } } public MapScreen implements Screen { @Override public void render(float delta) { } @Override public void show() { splashScreenInstance.dispose(); } @Override public void dispose() { if

How to make two bodies stick after a collision?

倾然丶 夕夏残阳落幕 提交于 2020-01-02 05:40:14
问题 I am really stuck on this I can successfully detect a collision but I can't make the two bodies involved in the collision to stick. Here is my ContactListener world.setContactListener(listener); listener = new ContactListener() { @Override public void preSolve(Contact contact, Manifold oldManifold) { } @Override public void postSolve(Contact contact, ContactImpulse impulse) { } //called when two fixtures cease to touch @Override public void endContact(Contact contact) { Fixture fixtureA =

Resetting the viewport after creating/rendering a scene2d Stage

百般思念 提交于 2020-01-02 05:15:14
问题 In my game I am drawing a scene2d Stage using a custom world coordinate system. I then want to draw a debug UI with some text like FPS on top of that, but simply using screen coordinates, i.e. where the text is positioned in the upper right corner of the screen. My main render method looks something like this: @Override public void render(float delta) { Gdx.gl.glClearColor(1, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); gameStage.act(delta); gameStage.draw(); debugInfo.render(delta); }

Flat shading in LibGDX

泄露秘密 提交于 2020-01-01 23:17:12
问题 I am currently working on a simple game and I would like to my terrain to be flat shaded. My terrain currently looks like the following: As you can see the colours blend toghether depending on the vertice colours. I would love for my end product to resemble the following: So I was wondering how can I achieve this? What are the steps to go from gouraud shading to flat shading? Here is how I go about creating the vertices I give to my mesh: public TerrainChunk() { buildHeightmap(); buildIndices

Flat shading in LibGDX

北城余情 提交于 2020-01-01 23:17:09
问题 I am currently working on a simple game and I would like to my terrain to be flat shaded. My terrain currently looks like the following: As you can see the colours blend toghether depending on the vertice colours. I would love for my end product to resemble the following: So I was wondering how can I achieve this? What are the steps to go from gouraud shading to flat shading? Here is how I go about creating the vertices I give to my mesh: public TerrainChunk() { buildHeightmap(); buildIndices

LibGDX texture blending with OpenGL blending function

扶醉桌前 提交于 2020-01-01 18:59:12
问题 In libGdx, i'm trying to create a shaped texture: Take a fully-visible rectangle texture and mask it to obtain a shaped textured, as shown here: Here I test it on rectangle, but i will want to use it on any shape. I have looked into this tutorial and came with an idea to first draw the texture, and then the mask with blanding function: batch.setBlendFunction(GL20.GL_ZERO, GL20.GL_SRC_ALPHA); GL20.GL_ZERO - because i really don't want to paint any pixels from the mask GL20.GL_SRC_ALPHA - from

LibGDX guidance - sprite tracing 2D infinite random bezier curve

耗尽温柔 提交于 2020-01-01 17:09:25
问题 I've been able to apply a smooth animation to my sprite and control it using the accelerometer. My sprite is fixed to move left and right along the x-aixs. From here, I need to figure out how to create a vertical infinite wavy line for the sprite to attempt to trace. the aim of my game is for the user to control the sprite's left/right movement with the accelerometer in an attempt to trace the never ending wavy line as best they can, whilst the sprite and camera both move in a vertical

Stenciling using OpenGl ES 2.0

ε祈祈猫儿з 提交于 2020-01-01 12:08:09
问题 I am trying to figure out a way to cut out a certain region of a background texture such that a certain custom pattern is not rendered on the screen for that background. For example: This square can be any pattern. I am using Frame Buffer Object and Stencil Buffer to achieve this kind of effect. Here is the code: fbo.begin(); //Disables ColorMask and DepthMask so that all the rendering is done on the Stencil Buffer Gdx.gl20.glColorMask(false, false, false, false); Gdx.gl20.glDepthMask(false);

Java/libGDX - how to check Polygon collision with Rectangle or Circle

隐身守侯 提交于 2020-01-01 11:42:11
问题 I'm new to libGDX and from what I can tell the Intersector class has overlap methods for Rectangle/Rectangle, Circle/Circle, Circle/Rectangle, and Polygon/Polygon, but for some reason it doesn't seem to have any methods for checking Polygon/Rectangle or Polygon/Circle. Is there a recommended way to check for collision between polygon and rect/circle? Also, is there some reason why this has been left out of the Intersector class? (ie, should I avoid it? If so, what's the recommended