Переглянути джерело

Basketball game: fix

customisations
alemart 8 місяці тому
джерело
коміт
d5d87c4130

+ 14
- 9
demos/basketball/src/entities/gui/gameover-overlay.js Переглянути файл

@@ -90,8 +90,7 @@ export class GameOverOverlay extends GUIControl
90 90
      */
91 91
     update()
92 92
     {
93
-        const container = this.control;
94
-        if(!container.isVisible)
93
+        if(!this.control.isVisible)
95 94
             return;
96 95
 
97 96
         const ar = this.ar;
@@ -99,12 +98,8 @@ export class GameOverOverlay extends GUIControl
99 98
             return;
100 99
 
101 100
         const pointer = ar.pointers[0];
102
-        if(pointer.phase != 'ended')
103
-            return;
104
-
105
-        // hide the overlay when touching the screen
106
-        container.isVisible = false;
107
-        this._broadcast(new GameEvent('gameoverdismissed'));
101
+        if(pointer.phase == 'ended')
102
+            this._dismiss();
108 103
     }
109 104
 
110 105
     /**
@@ -125,7 +120,7 @@ export class GameOverOverlay extends GUIControl
125 120
             container.isVisible = true;
126 121
         }
127 122
         else if(event.type == 'targetlost')
128
-            this.control.isVisible = false;
123
+            this._dismiss();
129 124
         else if(event.type == 'restarted')
130 125
             this._observedLongDistanceShot = false;
131 126
         else if(event.type == 'scored' && !this._observedLongDistanceShot)
@@ -133,6 +128,16 @@ export class GameOverOverlay extends GUIControl
133 128
     }
134 129
 
135 130
     /**
131
+     * Dismiss the Game Over screen
132
+     * @returns {void}
133
+     */
134
+    _dismiss()
135
+    {
136
+        this.control.isVisible = false;
137
+        this._broadcast(new GameEvent('gameoverdismissed'));
138
+    }
139
+
140
+    /**
136 141
      * Get the message to be displayed
137 142
      * @param {string} rank
138 143
      * @returns {string}

Завантаження…
Відмінити
Зберегти