libgdx

How to remove gaps between tiled textures?

China☆狼群 提交于 2019-11-27 16:19:11
问题 I'm using LibGDX to make a platformer. I'm using square tiles for the platforms but when they are drawn some of them have gaps between them. When I zoom in/out or move the camera around the gaps move position. More details: Tiles are 32x32 and I have tried both 32x32 and 64x64. Tiles are lined up 32 pixels apart (e.g. first tile would be x=0 y=0, second x=32 y=0, and so on in both x and y directions). The gaps are not texture artifacts as I have checked this. I use the TexturePacker with

“Tainted canvases may not be loaded” Cross domain issue with WebGL textures

假装没事ソ 提交于 2019-11-27 15:16:39
I've learnt a lot in the last 48 hours about cross domain policies, but apparently not enough. Following on from this question. My HTML5 game supports Facebook login. I'm trying to download profile pictures of people's friends. In the HTML5 version of my game I get the following error in Chrome. detailMessage: "com.google.gwt.core.client.JavaScriptException: (SecurityError) ↵ stack: Error: Failed to execute 'texImage2D' on 'WebGLRenderingContext': Tainted canvases may not be loaded. As I understand it, this error occurs because I'm trying to load an image from a different domain, but this can

Simulating palette swaps with OpenGL Shaders (in LibGDX)

 ̄綄美尐妖づ 提交于 2019-11-27 14:58:36
问题 I'm trying to use LibGDX to make a retro-style little game, and I'd like to let the players to choose the colors of several characters, so I thought about loading png indexed images and then updating palettes programatically... How wrong I was ^^U It seems that color pallettes are something of the past, and also seems that the best option to achieve a similar result is by using Shaders. Here is an image explaining what I'm trying right now: My intention is to use 2 images. One of them, pixel

Converting Android Bitmap to LibGdx's Texture

烈酒焚心 提交于 2019-11-27 14:53:55
i am trying to convert bitmap into a libGDX Texture by converting: Android Bitmap to byte[] byte[] to libGDX Pixmap libGDX Pixmap to libGDX Texture The problem I am facing is that the bitmap which is converted to texture is drawing the sprite sheet from texture packer that is in assets folder public void onByteArrayOfCroppedImageReciever(byte[] bytes) { try { pmap=new Pixmap(bytes, 0, bytes.length); tex=new Texture(pmap); face=new Sprite(tex); // game.setScreen(new GameScreen(game, batcher, face)); } catch(Exception e) { Gdx.app.log("KS", e.toString()); e.printStackTrace(); } } hmm another

Using scene2d.ui with libgdx: where does the skin come from?

感情迁移 提交于 2019-11-27 14:49:07
I've read about libgdx's scene2d features , including the UI elements, but I can't get them to work. They all seem to use a skin object, how do I create one? I've gone through the nice tutorial that creates a simple libgdx game catching raindrops in a bucket, and I've created a simple board game app by loading images with a texture atlas . However, scene2d sounds like a better way to control the moving pieces in a board game app, as well as any buttons and menus. Don Kirkby To load a skin, you can start with the sample skin files used in the libgdx test project. Atlaspack File Json File

Libgdx how to use shader in 3D

瘦欲@ 提交于 2019-11-27 14:12:09
问题 I reached a point in my wip game, where I want to make it more eye-appealing. Currently I add some Ambientlight and a Directionla-light to an Environment and render my scene with it. But now I want to add a custom Shader to it. So I have been looking for some tutorials and for some reason in almost every tutorial they have used another "version" of using Shader in their game: Giving the ModelBatch a String or FileHandle vertex/fragment -shader Creating a ShaderProgram with vertex and fragment

LibGDX - Get Swipe Up or swipe right etc.?

若如初见. 提交于 2019-11-27 14:00:00
问题 touch area http://imageshack.us/a/img836/2909/swipe1.png In the green area the user can swipe up, right, down, left. How can I now get e.g. swipe Up? or swipe Down? or swipe right or swipe left? e.g. how to get a String -> input = getSwiped(); -> input is then Up, or right, or down, or left And the user can touch two buttons. 1 or 2. 1 is for duck and 2 is for jump. I want to check this inputs at the same time. The user can touch and also swipe Up at the same moment. I know there is a

LibGDX: How to make tiled map tiles clickable?

≯℡__Kan透↙ 提交于 2019-11-27 13:46:39
How can I add click listeners for the tiles from tiled map so that when you select a tile with the mouse it becomes highlighted? That's not supported directly by libGDX as the TiledMap stuff is only for rendering. You could easily create a Stage though, which will act as some kind of overlay-input-layer for your TiledMap. Just create an Actor for each tile which has the same size as position as that tile. Then you are able to add EventListener s to those actors to be able to recognize things like clicks on those actors. Those actors should keep a reference to their "origin", namely

How get a string width in Libgdx?

柔情痞子 提交于 2019-11-27 12:44:22
I wonder know how to get the width of my string in pixels BitmapFont API < 1.5.6 To mesure the width of a String you use your Font and get the bounds of the String , you are going to draw. BitmapFont.getBounds(String str).width BitmapFont API You can get the height to for the right offset for drawing too. Just replace width with height. In addition for multiline texts use getMultiLineBounds(someString).width to get the bounds. BitmapFont API >= 1.5.6 The BitmapFont API changed in 1.5.7 so there is a different way to get the bounds now: BitmapFont.TextBounds and getBounds are done. Instead,

How to do blending in LibGDX

不想你离开。 提交于 2019-11-27 11:43:04
问题 I basically want to play around with blending modes in LibGDX but don't know how to do it. I found this image on internet. I want to do the same thing on LibGDX. Can someone teach me how. I've been playing around using Scene2D. Here's my non-working snippet. private class MyGroup extends Group { Image red, blue; public MyGroup() { Texture texture = new Texture(Gdx.files.internal("images/red.png")); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); red = new Image(texture);