libgdx

Flat shading in LibGDX

。_饼干妹妹 提交于 2019-12-04 20:51:34
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(); buildVertices(); calcNormals(indices, vertices); } public void buildHeightmap() {...} private void

how to import Universal tween engine in IntelliJ with lib gdx

≡放荡痞女 提交于 2019-12-04 19:46:35
okay.. I'm trying to create a splash screen for my mobile game. im using lib gdx library to create my game. i have a problem with importing the universal tween engine for my sprite splash. what should I do. I've downloaded the universal tween engine and extracted it in the "libs" folder in the ios, android, core, and root of my project.. and i copied and paste these lines for each dependencies: project(":core") { fileTree(dir: 'D:/game/core/libs', include: 'tween-engine-api.jar') compile fileTree(dir: 'D:/game/core/libs', include: 'tween-engine-api->sources.jar') project(":desktop") { compile

Why am I getting a blank screen when using shader?

浪子不回头ぞ 提交于 2019-12-04 19:28:40
I'm using this tutorial to create and draw an outline for my game Sprite s. However, all I get is a blank red screen. I'm very new to Shader s so I'm not sure if I'm missing something very trivial. My vertex and fragment shaders were copy-pasted from the above tutorial. (Commenting on the tutorial doesn't seem to work so I was unable to seek help there.) My code: float x = 0, y = 0, height = 256, width = 256, angle = 0, outlineSize = 1f; @Override public void create() { batch = new SpriteBatch(); img =new Texture("badlogic.jpg"); sprite = new Sprite(img); loadShader(); float w = Gdx.graphics

Drawing a CatmullRomSpline in libgdx with an endpoint and startpoint

社会主义新天地 提交于 2019-12-04 19:08:14
So my goal is to draw a spline similar to this one (where the line goes through each point): But the spline loops around (from the end point 2 back to the start point): I tried changing the "continuous" boolean in the catmullromspline, but that resulted in only a dot being drawn in the center of the screen. I also ended the line drawing when it hit the last point, but the result was ugly because the line was still curving at the start and end points. I looked everywhere in the source code, and could not find a function that could prevent it from looping. And as far as i know, bezier splines

Get vertice list of a polygon shape body

允我心安 提交于 2019-12-04 18:43:18
How do you get a list of vertices for a specific polygon body in libgdx? Like this : public Array<Vector2> getVerts(Body body){ Array<Vector2>verts = null; // can't find how to look them up properly anywhere return verts; } Thanks! Based on @James Webster's code: Array<Vector2> verts = new Array<Vector2>(); Fixture f = body.getFixtureList().get(0); PolygonShape s = f.shape; // this is needed to temporarily keep the vertex, getVertex is a void method Vector2 tmp = new Vector2(); for (int i = 0; i < s.getVertexCount(); i++) { // fill tmp with the vertex s.getVertex(i, tmp)); verts.add(new

Flickering object image movement in libgdx desktop app

白昼怎懂夜的黑 提交于 2019-12-04 18:29:32
This code makes image flicker while moving left,right,down or up. public class MoveSpriteExample extends GdxTest implements InputProcessor { Texture texture; SpriteBatch batch; OrthographicCamera camera; Vector3 spritePosition = new Vector3(); Sprite sprite; public void create() { float w = Gdx.graphics.getWidth(); float h = Gdx.graphics.getHeight(); batch = new SpriteBatch(); camera = new OrthographicCamera(); camera.setToOrtho(false, w, h); texture = new Texture(Gdx.files.internal("data/TestImg.png")); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); sprite = new Sprite(texture

Split a Texture into puzzle pieces In libgdx

有些话、适合烂在心里 提交于 2019-12-04 18:17:01
I am trying to convert android Canvas based game to Libgdx due to performance issues. Currently I am facing issues when I have to generate jigsaw puzzle piece sprites (dynamically). What I did : I used android bitmap manipulation (Path and PorterDuff) and generated puzzle pieces and then fed that to Libgdx Game object in AndroidLauncher. Question 1 : Is there a better way to convert a bitmap to puzzle pieces inside libgdx core project. (see below) Question 2 : How can I create an area just to represent the puzzle piece. (bounding box or width/height based solution is not suitable), so that

Libgdx: Moving a rotated perspective camera

允我心安 提交于 2019-12-04 17:41:46
I am developing an android app which visualize the map of an environment and currently i am using libgdx to draw the map, also like any map application the user should be capable of zoom, rotate and moving the map, I have developed a GestureHandler class which implements GestureListener interface and interacts with a PerspectiveCamera (since i will use 3d components in the future): @Override public boolean pan(float x, float y, float deltaX, float deltaY) { float tempX = (mapView.getCamera().position.x - deltaX * 0.5f); float tempY = (mapView.getCamera().position.y + deltaY * 0.5f); mapView

Is it possible to disable frame-limiting in libGDX?

时光怂恿深爱的人放手 提交于 2019-12-04 16:27:54
问题 More specifically, a desktop libGDX-LWJGL application. There are configurations options to disable CPU syncing as well as vsynching, but regardless the application runs at 60fps. This is fine for all practical uses - but out of curiousity if nothing else, I'd like to see how high the framerate could go. 回答1: Rode Hyde's answer is no longer correct due to changes in the library. Try this: LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.vSyncEnabled = false; /

why dont i have universal tween engine when setting up LibGDX

时光毁灭记忆、已成空白 提交于 2019-12-04 15:35:51
Following a tutorial on setting up A LibGDX project and the tutorial says that in the third party section there should be a Universal Tween Engine. Mines not showing up, is there a way for it to show up? What do i have to download? Thanks in advance :)) The Gdx-setup-new-ui-jar does not come with TweenEngine library. There is another way of adding Universal TweenEngine. Since you are using Gradle now, so it is very easy. just download the TweenEngine from here https://code.google.com/p/java-universal-tween-engine/downloads/list and paste it in your core/libs android/libs and ios/libs folders.