Commit a17662e6 authored by Viktor Lidholt's avatar Viktor Lidholt

Adds delay between game over and return to main screen in demo game

parent 7be4e421
...@@ -46,6 +46,7 @@ class GameDemoWorld extends NodeWithSize { ...@@ -46,6 +46,7 @@ class GameDemoWorld extends NodeWithSize {
// Game state // Game state
int _numFrames = 0; int _numFrames = 0;
bool _isGameOver = false; bool _isGameOver = false;
int _gameOverFrame;
int _currentLevel = 0; int _currentLevel = 0;
// Heads up display // Heads up display
...@@ -320,6 +321,11 @@ class GameDemoWorld extends NodeWithSize { ...@@ -320,6 +321,11 @@ class GameDemoWorld extends NodeWithSize {
if (_numFrames > _numFramesShieldActive) _shield.visible = false; if (_numFrames > _numFramesShieldActive) _shield.visible = false;
else if (_numFrames > _numFramesShieldActive - _numFramesShieldFlickers) _shield.visible = !_shield.visible; else if (_numFrames > _numFramesShieldActive - _numFramesShieldFlickers) _shield.visible = !_shield.visible;
// Check for exit back to main screen
if (_isGameOver && _numFrames - _gameOverFrame == 60) {
_navigator.pop();
}
_numFrames++; _numFrames++;
} }
...@@ -350,6 +356,7 @@ class GameDemoWorld extends NodeWithSize { ...@@ -350,6 +356,7 @@ class GameDemoWorld extends NodeWithSize {
// Set game over // Set game over
_isGameOver = true; _isGameOver = true;
_gameOverFrame = _numFrames;
_gameOverCallback(_hud.score); _gameOverCallback(_hud.score);
// Remove the ship // Remove the ship
...@@ -357,8 +364,6 @@ class GameDemoWorld extends NodeWithSize { ...@@ -357,8 +364,6 @@ class GameDemoWorld extends NodeWithSize {
// Add an explosion // Add an explosion
addExplosion(AsteroidSize.large, _ship.position); addExplosion(AsteroidSize.large, _ship.position);
_navigator.pop();
} }
// Handling controls // Handling controls
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment