I am new to Android and have learned a lot with this project. I am almost there but, but one of my missing parts is... the game does something like the Simon Says game, and right now I am able to click on the Images and it also loops through them for t开发者_如何学Che user but I can touch them while the loop goes through them. I want now to be able to set like a boolean flag that says userTurn if 0 then it's user turn and if 1 then its the system. Something of that sort.
What would be the best way to approach this?
If the various states in which your application can be in is very large and/or complex, I would recommend the state pattern. But if you just need two states, either system or user, I would use something like this:
private boolean isSystemTurn = false;
and then check it like that:
if (isSystemTurn) {
// the user has to wait
} else {
// it is user turn
}
精彩评论