Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why game is running slow in libgdx?

Tags:

libgdx

I am making racing game in Libgdx.My game apk size is 9.92 mb and I am using four texture packer of total size is 9.92 Mb. My game is running on desktop but its run on android device very slow. What is reason behind it?

like image 360
Vishal Singh Avatar asked Nov 26 '22 21:11

Vishal Singh


1 Answers

There are few loopholes which we neglect while programming. Desktop processors are way more powerful so the game may run smoothly on Desktop but may slow on mobile Device.

Here are some key notes which you should follow for optimum game flow:

  1. No I/O operations in render method.
  2. Avoid creating Objects in Render Method.
  3. Objects must be reused (for instance if your game have 1000 platforms but on current screen you can display only 3, than instead of making 1000 objects make 5 or 6 and reuse them). You can use Pool class provided by LibGdx for object pooling.
  4. Try to load only those assets which are necessary to show on current screen.

Try to check your logcat if the Garbage collector is called. If so than try to use finalize method of object class to find which class object are collected as garbage and try to improve on it.

Good luck.

like image 123
Kumar Saurabh Avatar answered Jun 16 '23 19:06

Kumar Saurabh