Skip to content

Instantly share code, notes, and snippets.

@MarcinusX
Last active January 14, 2019 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarcinusX/567d40768024e6b1a0089ddd5b9fc3b9 to your computer and use it in GitHub Desktop.
Save MarcinusX/567d40768024e6b1a0089ddd5b9fc3b9 to your computer and use it in GitHub Desktop.
@override
void initState() {
super.initState();
animationController = AnimationController(vsync: this, duration: Duration(milliseconds: 300));
animationController.addStatusListener((status) {
if (status == AnimationStatus.completed && isPlaying) { //<-- Add this check
if (notes[currentNoteIndex].state != NoteState.tapped) { //<--Add this check
//game over
setState(() {
isPlaying = false; //<--Stop the game
});
} else if (currentNoteIndex == notes.length - 5) {
//song finished
} else {
setState(() => ++currentNoteIndex);
animationController.forward(from: 0);
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment