Just getting into android coding and I was looking at this very useful tutorial 'Getting Started in Android Game Development'.
It outlines a basic 'main loop':
public void run() {
while (isRunning) {
while (isPaused && isRunning) {
sleep(100);
}
update();
}
}
private void update() {
updateState();
updateInput();
updateAI();
updatePhysics();
updateAnimations();
updateSound();
updateVideo();
}
Ok, so far so good. But he also states that games should have their own thread so that thread interrupts handle well.
So should I have a main activity that spawns a surfaceview with a thread in it? (like the lunarlander game), and shouldnt the main loop be in that thread then?
So in that case I would have a main activity, perhaps a main menu, which spawns a new activity for the game / screen and also contains the main thread? My game will have two modes, which should each have an activity, right? How do I make sure the thread is calling both activities correctly? I know one activity can be inside another but it seems messy. I would have thought that the better way to do it would be to have the main thread independent of the activities?
Little bit confused here about activities, threads etc. Please ask me if you don't understand me; when starting out it is often not easy to decribe what you don't know very well!
Cheers
Ed