瀏覽代碼

Basketball game: fix

customisations
alemart 8 月之前
父節點
當前提交
d5d87c4130
共有 1 個檔案被更改,包括 14 行新增9 行删除
  1. 14
    9
      demos/basketball/src/entities/gui/gameover-overlay.js

+ 14
- 9
demos/basketball/src/entities/gui/gameover-overlay.js 查看文件

90
      */
90
      */
91
     update()
91
     update()
92
     {
92
     {
93
-        const container = this.control;
94
-        if(!container.isVisible)
93
+        if(!this.control.isVisible)
95
             return;
94
             return;
96
 
95
 
97
         const ar = this.ar;
96
         const ar = this.ar;
99
             return;
98
             return;
100
 
99
 
101
         const pointer = ar.pointers[0];
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
             container.isVisible = true;
120
             container.isVisible = true;
126
         }
121
         }
127
         else if(event.type == 'targetlost')
122
         else if(event.type == 'targetlost')
128
-            this.control.isVisible = false;
123
+            this._dismiss();
129
         else if(event.type == 'restarted')
124
         else if(event.type == 'restarted')
130
             this._observedLongDistanceShot = false;
125
             this._observedLongDistanceShot = false;
131
         else if(event.type == 'scored' && !this._observedLongDistanceShot)
126
         else if(event.type == 'scored' && !this._observedLongDistanceShot)
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
      * Get the message to be displayed
141
      * Get the message to be displayed
137
      * @param {string} rank
142
      * @param {string} rank
138
      * @returns {string}
143
      * @returns {string}

Loading…
取消
儲存