I started making a new game for the thousandth time and the biggest problem I have been having in each one is how slow they are running. I’m using libgdx so I can bring it to other platforms when I want to. I think it must be how I’m doing the levels. I’m just going to have a class for each level with 3 z levels represented by 3 2d arrays (you’ll see). Later I’m going to change it to load from a file. If someone can just look over it and tell me if I’m doing something wrong that would help.
rar file? Is this a 90s warz site?
Cut it down to the smallest example you can. We are not going to read your whole project.
Hi
You use a SpriteBatch. Each “object” is handled as a Sprite. I’ve found nothing obvious that could hurt the performance but I’m not an expert of LibGDX and I use another backend (it shouldn’t affect the framerate anyway).
I guess I’m gonna check how much time is each part is taking and maybe that could show me whats doing it. Also I opened task manager to and saw it gobbling up a massive amount of memory so I’m guessing that’s probably going to be the problem.
Its the very start of the game. I wouldn’t know where to begin to break it down into a example since it spans a game, world object handler and objects class, and the objects themselves. So I took down the file and I’ll just keep on it myself.
I’m happy I checked task manager. I noticed that it was reloading the texture at every render for every sprite and changed it to load up once inside the render method with a boolean and it fixed it. Weird thing though it uses more memory and cpu on my better computer than my laptop. Desktop 4 cores at 4.5ghz, 8 gigs ram and a GeForce 670 and my laptop has 2 cores at 2ghz, 3 gigs ram, and a mobile ati 4100. From the task manager Desktop - CPU:25, Mem:80k and the Laptop CPU:6-10, Mem:41k. My desktop is 64bit and uses 64bit java so maybe that’s it?
Why not just load the textures in the create method? Or use a spritesheet with TextureRegions?
I have the objects like floor tiles extend a objects class and the object class calls for a method that returns the string name of the tile. It is null in the constructor. I’m gonna do it a better way pretty soon once I can get to it. When it creates the tiles I’ll just put a string in the constructor for it.
add(new Floor(x,y, "floor")