Skip to content

Commit 8c3a1e8

Browse files
committed
修正测试页游戏舞台销毁方法
1 parent 54b87cb commit 8c3a1e8

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

public/index.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
border: 1px solid #999;
3838
overflow: auto;
3939
box-sizing: border-box;
40+
z-index: 10;
4041
}
4142

4243
div.file-select .unsupported-audio-file-type.warn {
@@ -52,10 +53,11 @@
5253
right: 0;
5354
}
5455

55-
canvas#canvas {
56+
.canvas-game {
5657
position: absolute;
5758
top: 0;
5859
left: 0;
60+
z-index: 1;
5961
}
6062

6163
div.play-result,
@@ -72,6 +74,7 @@
7274
border-radius: 14px;
7375
box-shadow: 0px 0px 24px #000;
7476
box-sizing: border-box;
77+
z-index: 10;
7578
}
7679
div.play-result .title,
7780
div.game-paused .title {
@@ -172,6 +175,7 @@
172175
background-color: #F33;
173176
border: 1px solid #A00;
174177
box-sizing: border-box;
178+
z-index: 20;
175179
}
176180
div.error-window a {
177181
color: #FFF;

src/game.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,13 @@ export default class Game
389389
this.chart.reset();
390390
this.chart.destroySprites();
391391
this.judgement.destroySprites();
392-
this.render.destroy(removeCanvas, { children: true, texture: false, baseTexture: false });
393392

394393
this.judgement.input.removeListenerFromCanvas(canvas);
395394
window.removeEventListener('resize', this.resize);
396395

397396
canvas.width = canvas.height = 0;
397+
398+
this.render.destroy(removeCanvas, { children: true, texture: false, baseTexture: false });
398399
}
399400

400401
_pauseBtnClickCallback()

src/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,6 @@ doms.startBtn.addEventListener('click', async () => {
448448
assets: assets,
449449
zipFiles: files.zip,
450450
render: {
451-
canvas: doms.canvas,
452451
resizeTo: document.documentElement,
453452
resolution: doms.settings.lowResolution.checked ? 1 : window.devicePixelRatio,
454453
antialias: doms.settings.antiAlias.checked,
@@ -474,6 +473,9 @@ doms.startBtn.addEventListener('click', async () => {
474473
watermark: 'github/MisaLiu/phi-chart-render ' + GITHUB_CURRENT_GIT_HASH
475474
});
476475

476+
document.body.appendChild(_game.render.view);
477+
_game.render.view.classList.add('canvas-game');
478+
477479
_game.on('start', () => console.log('Game started!'));
478480
_game.on('pause', () => {
479481
console.log('Game paused!');
@@ -689,7 +691,7 @@ function exitGame()
689691
{
690692
if (!_game) return;
691693

692-
_game.destroy();
694+
_game.destroy(true);
693695
_game = undefined;
694696

695697
qs('.game-paused').style.display = 'none';

0 commit comments

Comments
 (0)