Hot answers tagged

3

I don't think you can fix that "loading" issue, if your game has to open a file from HDD, load the content, parse it and draw it there's nothing to do that could speed it up. I would say that, the best you can do is store the whole map in memory and get chunks more often, like 100m sou you should be able to high speed reading from ram and the lag would ...


3

The texture regions inside don't need to be powers of two. But texture compression cells are often 4x4 so you have to be careful when using compressed textures that the edges of two texture regions don't share the same cell or they'll be compressed together which will degrade the quality if they have different colors. You should leave a N pixel border ...


3

Have you considered playing the sound when the direction of the ball changes? Or like add that as a condition, in addition to the already "collide with object" condition.


3

You seem to lack some insight on your issue. A couple of things to consider: Is your true maximum frame rate on your PC really 60 or is it more? NVida drivers limit the frame rate to the maximum draw rate of the monitor, typically 60 Hz; this is due to the fact that there is no need to ask to draw faster than what the monitor is able to process. By ...


2

Scene2D already checks if an Actor is on your viewport or not. You don´t need to code that. Edit: I´m searching on the Scene2D documentation about this, I can´t find it, but I know it is true, if someone can help me and link it, that would be nice :) I think it is necessary to add a reference to the documentation for this answer.


2

I'm not sure if its a good solution but i use to add x, y and z (gonna call this XYZ from now) and store it in a linked list with an object identifier and the average side size (we gonna asume that, in this example the object is a cube of 20x20x20 so 20*3/3 = 20). //PSEUDOCODE MYOBJECT ob(/*id*/ 1, /*size*/ 20, /*x*/ 30, /*y*/ 12, /*z*/ 4); ...


2

As people have said in comments section, A* or (AStar) is a viable algorithm for this, and a good waypoint. Here you have a generic AStar implementation in Java so you can start with something. Please, ask if you have any question. import java.util.*; public class AStar { public static class PriorityList extends LinkedList { public void ...


2

Sounds like you're looking for the vector magnitude, also called (depending on context) its length, Euclidean norm, or Pythagorean Theorem. ie. speed = sqrt(dot(velocity, velocity)); As Alexandre Vaillancourt points out, in libGDX the len() method does exactly this. Other environments will almost always have an equivalent (eg. in Unity it's .magnitude) ...


2

If I understand the problem correctly, you were close to properly solving it. Your approach with the normals is what you want, but instead of only saving the normal of the last collision, save a list of normals from all current collisions/overlappings. Then, play the sound whenever the new normal of the new collision is not yet present in the list. In ...


2

You can find all what you need here Tile maps class, and read the section Rendering Tiled Maps according to Libgdx docs: Performance considerations While we try to make the renderers as fast as possible, there are a few things you can consider to boost rendering performance. Only use tiles from a single tile set in a layer. This will reduce ...


2

As suggested in the comments, you should try to use Tri-Linear filtering and MipMaps. The reason using TextureFilter.MipMapLinearLinear results in a black box is that you haven't generated the texture with MipMaps. In order to do so, simply pass a second parameter to the Texture constructor as true like so: img = new Texture("circle.png", true);


2

You shouldn't call dispose directly on a Texture loaded by an AssetManager, they are disposed the the AssetManager is cleared or disposed or if you call unload on the AssetManager and pass the Texture. The reason you shouldn't dispose assets from an AssetManager is that they can be shared between many other assets (two fonts may use the same texture for ...


1

It's a bit vague what you want to do and what you have. But this should help: Vector3 pos = new Vector3(); Matrix4 nodeTransform = new Matrix4(); nodeTransform.setToTranslation(2, 4, 0).rotate(Vector3.Z, 180f); nodeTransform.getTranslation(pos); Gdx.app.log("Node pos", pos.toString()); Matrix4 modelTransform = new Matrix4(); ...


1

Create the menu in one Activity, and let that Activity be a "normal" Android activity, then have that Activity launch the libGDX game Activity. That sort of approach would allow you to use Android layouts for the menu but libGDX for the actual game.


1

One way to do this would be to clamp (limit) the x and y values of the camera to your width and height of the game. It may look something like this: Clamp method: public int clamp(int var, int max, int min) { if(var > min) { if(var < max) { return var; } else return max; } else return min; /* * var = your variable ...


1

I reccomend you delete and load smaller pieces (~50m) at a time to keep a more stable (if not lower) fps.


1

From you code I can't tell what the ownerv vector is so I can't tell you why it's giving you the wrong result. But to do it from scratch, according to Wikipedia's article on vector projection, you can do the following; Create a vector a that is the direction from o to v. Create a vector b that is the direction from o to n. Let d be the dot product of a ...


1

Ok, I'm piggy-backing on Skitskraj's answer here so if you like mine, upvote his/hers too. Solution: Play the sound only if there is a new contact and there is a significant velocity change. I would suggest using the postSolve callback on the first iteration of the collision to determine if the impulse is above some threshold value required to generate the ...


1

One way to approach this would be to represent the definition of the first bodies as Rectangles, then the problem of figuring out the position and rotation of the bridges goes aways as the bridge is always made up as a polygon touching the top corners of the Rectangle. The above image was generated using this approach, full source code below. It uses ...


1

What you are seeing in the video is just an animated background image , You can try to create your owen using sprite sheet animation techniques ( see here ) take a look here also : Animated background using Libgdx


1

Yes, it does. But in case you want to be sure, you can check it yourself using Frustrum to compare performances. (If using Frustrum increases performance, then it Scene2D does not check if an actor is on screen or not, renders everything, but this won´t happen). Frustum


1

According to the documentation (SelectBox.addListener), this element seems to reacting only to 'touch' and 'click' related events, not to keyboard related events. Perhaps you could try and use the stage events instead.



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