Game Loop - Using Timer instead of "while()"?

Put your problem here if it does not fit any of the other categories.

Game Loop - Using Timer instead of "while()"?

Postby Don Pipo » Wed Feb 09, 2011 11:58 am

Hi everybody!

I try to move from Flash/AS3 to Android/Java and read a lot of tutorials in the last days. If I stumble over Android game tutorials I always find something like this:

Code: Select all
public void run() {
    Canvas c;
    while (_run) {
        c = null;
        try {
            c = _surfaceHolder.lockCanvas(null);
            synchronized (_surfaceHolder) {
                // simulate and render game here
            }
        } finally {
            // don't leave the Surface in an
            // inconsistent state
        }
    }
}


I have never seen a game loop created with "while()" in Flash. In Flash I used a Timer-class to create my game loop. Does this have a Android or Java related reason?

Thanks!
Pipo
Don Pipo
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Feb 09, 2011 11:42 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Majestic-12 [Bot] and 17 guests