Quote: "You don't need T2 to make a state machine."
Absolutely correct.
My point is that you need a state machine (or something like it) to deal with a particular issue in how Sync() and the main 'do' loop are handled in Tier 2.
Here is an excerpt from the demo being worked on:
Why is a state machine needed?
The reason a state machine is needed in Tier 2 is because of how user and device inputs are handled.
In Tier 1 any call to Sync() will update the display, physics, user inputs (pointer, keyboard, touches, etc.) and device inputs (accelerometer, camera, HTTP interactions, etc.).
In Tier 2 a call to agk::Sync() does NOT update the user and device inputs. The user and device inputs are updated at the end (or beginning?) of each app::Loop() method execution. The app::Loop() method takes the place of the main 'do...loop' in Tier 1.
In Tier 1 you can do something like this and easily get to the statement after 'endwhile' by touching the app:
// set up stuff
Print("Touch anywhere to continue")
// wait for user
while GetPointerPressed() = 0
// repeat the instructions because Print only lasts
// until the next Sync() call
Print("Touch anywhere to continue")
// update to check for user input
Sync()
endwhile
// continue doing stuff
Print("Okay, let's get going")
But in Tier 2, the equivalent loop will be totally hung (note how relatively easy it is to convert Tier 1 to Tier 2):
// set up stuff
agk::Print("Touch anywhere to continue");
// wait for user
while (GetPointerPressed() == 0)
{
// repeat the instructions because Print only lasts
// until the next Sync() call
agk::Print("Touch anywhere to continue");
// update to check for user input
agk::Sync();
}
// continue doing stuff
agk::("Okay, let's get going");
So, if you are doing anything that requires input from the user or the device, it must be handled differently than you would in Tier 1.
While it is a bit annoying to have to go the extra steps, it actually allows a lot more control. It also lets you think more about discrete processes (states) and a little less about top to bottom coding.
Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master