Skip to content Skip to sidebar Skip to footer

Using A Thread As A Gameloop

What I need to do is have a loop that I can stop if I want... I made a new thread and named it GameLoop I want this to do all of my bitmap X and Y changes but when I tryed to run w

Solution 1:

Use two nested while loops as so:

@Overridepublicvoidrun() {
    while (gameShouldRun) {
        while (iterateGame) {
            // do game stuff
        }
    }
}

Also, run is not looped by default. If you want the game to loop until stopped, you will need a while loop in the run method.

Post a Comment for "Using A Thread As A Gameloop"