Hot answers tagged

4

The Android memory profilers that comes with the Android Developer Tools will allow you to figure out what is consuming your memory. It comes in three parts; Memory Monitor (this is used to find performance problems, so we can ignore this one for this particular problem). Tool Heap Viewer Allocation Tracker Using the Heap Viewer you can take snap-shots ...


3

I would take a look at glDraw*Instances (Instancing) Also, reducing vertex count for a large amount of small particles is extremely important. I don't know if your using a model or a single 2D texture or what, but some general tips: Use as few verticies as possible. If using transparency in your textures, use glAlphaFunc to reduce blending needed. If ...


3

If you're definitely only ever going to have one instance of these objects, and presumably you are, then this would be a better way to go. However, maybe a better solution would be to use the Singleton pattern, and (for example) create a static GetScreen() method in the Screen class that any other class can call to obtain the single instance of the Screen ...


2

You can store the values in a database,It is simple if you use database like sqlite but that wont work with libgdx -android. Instead you can use gdx-sqlite gdx-sqlite is a cross-platform Libgdx extension for SQLite database handling. The extension abstracts databse handling to provide a unified method to handle database transacitons across multiple ...


2

At least i have found the solution. It includes 2 step : 1- My surface texture wraping was wrong. X axis must be repeated and Y axis must be clamped to edges. The correct one is: surfaceTexture.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.ClampToEdge); 2- When we use "ClampToEdge" wrapping, texture's Y coordinates must be between 0 and 1. So i ...


2

The difference between ScreenSize and WorldSize is part of the brilliance of graphics systems like OpenGL. ScreenSize is the actual size of the window in pixels. When the user grabs the window handles and resizes the window, then ScreenSize will change. WorldSize is the size of your game level or "World". It is completely arbitrary. In a 2D game, 1 unit in ...


1

From my experience, it's not expensive to bind textures. I have a program that binds about 30 textures per frame and it runs pretty smooth. Since you're using only 9 textures and VBOs on top of that, I imagine your game actually runs very well.


1

There may be a better/more efficient way to do it, but an easy way would be to draw a tinted, mostly transparent circle on top of an actor. (Or beneath the actor if you don't want the actor itself tinted.) If you have a white circle texture and want a red aura, then the draw code would look like this Color oldColor = batch.getColor(); ...


1

Yes. It is possible. Any of the scene2dUI widgets, like Table, inherit from Actor. Actor has a setVisible(boolean isVisible) member that will hide it and all of its children and disable any touch events to it. You just have to make sure that your menu or game instructions are in front of your Game view by adding them to your Stage last. You will also need ...


1

You should probably take a look at Scene2D's Window class. Think of it as a screen that just overlays other screens. It's also a Table, which means you can add buttons or any other Actor to it just like any other table. This also means you can directly add it to your Stage, if you wish. A simple pause screen would be something like this: Window pause = new ...


1

My guess to why it is choppy is because scl() is permanently scaling your velocity by deltaTime each update call. Since deltaTime varies a little from frame to frame, this causes the choppiness. Change the position update to float velocityX = player.getVelocity().x; float velocityY = player.getVelocity().y; player.getPosition().add(velocityX * ...


1

you can do like this: In your hud class public jumpButtonPressed = false; buttonJump.addListener(new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { jumpButtonPressed = true; return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { ...


1

Dont know how your particle system is written but it is very possible that your bottle neck is the communication time between CPU and GPU. Not going to go into too much detail but just know that this operation can be very slow because it causes stalling. Perhaps the idle time you see in profiling is due to that. What a good particle system do is to move all ...


1

I'm not going to go into details, but what you should be looking into is something like WinAMP's MilkDrop plugin presets and porting them to a shader. A good selection of example shaders (and how to write them) can be found at https://www.shadertoy.com/. These examples run on WebGL and use the GLSL language to render procedural content that is usually fast ...


1

According to this post you can draw a rotated quad. The line texture could be a 1x1 colored pixel. public static void drawLine(Batch batch, float x1, float y1, float x2, float y2, float lineWidth, TextureRegion lineTexture) { float xdif = x2-x1; float ydif = y2-y1; float l2 = xdif*xdif+ydif*ydif; float invl = (float)(1/Math.sqrt(l2)); //dif is ...


1

The screen coords go from {-1,-1} to {1,1} but you are most likely feeding it {0,0} to {1,1} - hence the fact that only one-quarter of the screen gets rendered. So just to be clear - point {0,0} is not the top-left (or bottom-left, depending on your co-ordinate system) point; it's the center. This also explains the texture coord tranformation that you are ...


1

If you want to use sqlite with libGdx you can use opensource project gdx-sqlite . gdx-sqlite is a cross-platform Libgdx extension for SQLite database handling. The extension abstracts database handling to provide a unified method to handle database transacitons across multiple platforms while also adding SQLite support for desktop version of Libgdx ...



Only top voted, non community-wiki answers of a minimum length are eligible