libgdx

how to draw custom shapes using a simple texture in libgdx?

为君一笑 提交于 2019-12-03 07:35:45
I want to draw custom static shapes in my game just like the angry birds done: but the problem is that the texture is in square shape. how we can tell to the "SpriteBatch" to draw shapes with some vertices? does anybody has some ideas? According to the docs : A SpriteBatch is used to draw 2D rectangles that reference a texture (region) So essentially, this method does not allow you to specify any other geometry than a rectangle. However, there is a draw method that allows you to specify the four coordinates of the "rectangle" and turn it into something else. You'd've to decompose the geometry

Why do I have lines going across my libgdx game using Tiled?

删除回忆录丶 提交于 2019-12-03 07:33:31
I'm using LibGdx and Tiled and when moving around the screen, there are both horizontal and vertical lines appearing on the game. I can post any code you need, if necessary. How do I get these lines to stop? Here's a gfycat gif of the lines: http://gfycat.com/FastUnnaturalAmericanwirehair Edit: Here's a small bitbucket repository, as small as I could get it that has the same glitch in it: https://bitbucket.org/Chemical_Studios/example-of-line-glitch/src/8eeb153ec02236d836763072611bd7aa55d38495/minimalExample/src/com/weebly/chemicalstudios/minEx/?at=master noone This is because you need to add

Updating android app with Libgdx for 64-bit devices

 ̄綄美尐妖づ 提交于 2019-12-03 06:44:40
I have handful of apps in android on google play. I just need to update the app as per the below requirement mentioned by google recently. i.e., all the app has to be compatible with 64-bit . https://android-developers.googleblog.com/2019/01/get-your-apps-ready-for-64-bit.html Questions: what code changes is needed in the app to make it compatible with 64-bit devices ? Do we have 64-bit version of LibGdx available ? If there is no 64-bit LibGdx available is there is any other work around to resolve this ? I've also received that email from Google and started to wonder if my game is compatible

Remove Actors from Stage?

杀马特。学长 韩版系。学妹 提交于 2019-12-03 06:08:17
I use LibGDX and move only the camera in my game. Yesterday I founded a way to draw the ground in my game. I'm trying to make a clone of Flappy Bird, but I have problems with drawing the ground which is moving on the screen. In every render call I add a new Actor to the Stage , but after a few times the drawing is no more flowing. The frames per second sink very fast. Is there another way to draw ground in games? If I'm reading correctly, you're problem is that once actors go off the screen, they are still being processed and causing lag, and you want them to be removed. If that's the case,

When to use ShapeRenderer, Mesh + SpriteBatch, Box2D and Scene2D in Libgdx?

◇◆丶佛笑我妖孽 提交于 2019-12-03 06:04:41
I'm new in Android Game Development and after I started with libgdx ShapeRenderer and did a little more search, I became confused if I started with the right foot. So, what I really would like to know is when should I use ShapeRenderer, Mesh + SpriteBatch, Box2D and Scene2D. P.T. LibGDX has quite a lot of (mostly orthogonal) APIs for rendering. I'm still learning my way around many of them, but I can give an overview of the different parts. ShapeRenderer lets you quickly and easily put basic flat-colored polygons and lines on the screen. Its not particularly efficient (it uploads a lot of

Get cursor position in LIBGDX

爷,独闯天下 提交于 2019-12-03 05:18:11
How to get cursor position in libgdx and apply it to sprite? Like this? I want my sprite to have the direction pointed wherever my cursor is in the screen.I search libgdx examples but i cant find any examples related to that. Get cursor position If you're polling for input, use Gdx.input.getX() and Gdx.input.getY() to get the current mouse x and y coordinates. (The doc says its only relevant for touch, but the code looks like it reports raw mouse values regardless of button state.) If you're using an InputProcessor you can use one of: touchMoved callback (on older libGDX versions) mouseMoved

android gdx sound performance issue

好久不见. 提交于 2019-12-03 05:11:19
I'm building a scrolling shooter with libgdx. in windows, everything runs just fine, but on android i get noticeable jitter and the framerate drops from 61 fps avg without sound to 48-56 fps avg with sound. it plays a lot of small sound effects concurrently as there are a lot of bullets to fire and enemies to hit at once. my sound routine: import com.badlogic.gdx.Gdx; import com.badlogic.gdx.audio.Sound; public class SoundFX { static final int BGDIE = 1, BGHIT = 2, BGLASER = 3, BGSPAWN = 4, PDIE = 5, PHIT = 6, PLASER = 7, PSPAWN = 8, PAUSE = 9; Sound S_BGDIE, S_BGHIT, S_BGLASER, S_BGSPAWN, S

Scale a Bitmapfont in LibGDX

独自空忆成欢 提交于 2019-12-03 05:02:39
How can I scale a Bitmapfont object in LibGDX? It seems the method setScale is no longer available. It is not recommended to scale Bitmap font, because it looks pixlated when enlarged(which I believe is ugly) It is recommended to use freetype generator for resizing your fonts If you still want use bitmapFont Tenfour04 is correct Use bitmapFont.getData().setScale(float x, float y) . Nasser Tahani As Fish mentioned, it is recommended to use freetype generator as following: FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/timesBold.ttf"));

Android libgdx big screen resolution

非 Y 不嫁゛ 提交于 2019-12-03 04:53:08
How can I support (make an algorithm) for libgdx for supporting multiple screen resolution? I made my app work on HTC Tattoo using if statments with parameters like: if (Gdx.input.getX()==40) { What is a good algorithm for making this work on bigger screens? I tried this but without any result: publis static int translatex() { float p = (float)Gdx.graphics.getHeight()*340; return (int) p*Gdx.input.getX(); } 340 is the base x (the x resolution on my phone) used by me on the HTC Tattoo. So.....how can I make a function for supporting big screens with absolute values. I don`t want to change the

How to get screen resolution of an android device using LIBGDX?

别等时光非礼了梦想. 提交于 2019-12-03 04:50:22
I am working android game development and I am new in it. I want to develop a game which screen resolution free. It will be enough for me if i get to know that how to catch screen resolution of an android device using libgdx library. After some googling i read the following code on different sites, but it is not for libgdx. DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); height = displaymetrics.heightPixels; width = displaymetrics.widthPixels; Except this i also used technique given on the following website that used