Search code examples
androidandroid-studiosurfaceviewrunnable2d-games

How to modify my app/game so that it can load quickly?


I have created a simple game using a class a which extends SurfaceView and implements Runnable. In the game the drawing is done inside the public void run. Which is targeted by a thread as soon as the activity launches. The game is taking a lot of time(sometimes 10-15 sec) to load. As well as when the game is paused(thread. join()) and resumed(thread = new Thread(this); thread.start()) it takes too much time. What might be making the game load slow? And what can be the solutions?


Solution

  • I found that the game was loading slow because the thread has been running continuously, without any sleep. So just adding Thread.sleep(15); inside the run, with all exceptions handled, solved this problem. Thank you for supporting.