Skip to content

Commit

Permalink
修正测试页游戏舞台销毁方法
Browse files Browse the repository at this point in the history
  • Loading branch information
MisaLiu committed Nov 1, 2022
1 parent 54b87cb commit 8c3a1e8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion public/index.html
Expand Up @@ -37,6 +37,7 @@
border: 1px solid #999;
overflow: auto;
box-sizing: border-box;
z-index: 10;
}

div.file-select .unsupported-audio-file-type.warn {
Expand All @@ -52,10 +53,11 @@
right: 0;
}

canvas#canvas {
.canvas-game {
position: absolute;
top: 0;
left: 0;
z-index: 1;
}

div.play-result,
Expand All @@ -72,6 +74,7 @@
border-radius: 14px;
box-shadow: 0px 0px 24px #000;
box-sizing: border-box;
z-index: 10;
}
div.play-result .title,
div.game-paused .title {
Expand Down Expand Up @@ -172,6 +175,7 @@
background-color: #F33;
border: 1px solid #A00;
box-sizing: border-box;
z-index: 20;
}
div.error-window a {
color: #FFF;
Expand Down
3 changes: 2 additions & 1 deletion src/game.js
Expand Up @@ -389,12 +389,13 @@ export default class Game
this.chart.reset();
this.chart.destroySprites();
this.judgement.destroySprites();
this.render.destroy(removeCanvas, { children: true, texture: false, baseTexture: false });

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

canvas.width = canvas.height = 0;

this.render.destroy(removeCanvas, { children: true, texture: false, baseTexture: false });
}

_pauseBtnClickCallback()
Expand Down
6 changes: 4 additions & 2 deletions src/index.js
Expand Up @@ -448,7 +448,6 @@ doms.startBtn.addEventListener('click', async () => {
assets: assets,
zipFiles: files.zip,
render: {
canvas: doms.canvas,
resizeTo: document.documentElement,
resolution: doms.settings.lowResolution.checked ? 1 : window.devicePixelRatio,
antialias: doms.settings.antiAlias.checked,
Expand All @@ -474,6 +473,9 @@ doms.startBtn.addEventListener('click', async () => {
watermark: 'github/MisaLiu/phi-chart-render ' + GITHUB_CURRENT_GIT_HASH
});

document.body.appendChild(_game.render.view);
_game.render.view.classList.add('canvas-game');

_game.on('start', () => console.log('Game started!'));
_game.on('pause', () => {
console.log('Game paused!');
Expand Down Expand Up @@ -689,7 +691,7 @@ function exitGame()
{
if (!_game) return;

_game.destroy();
_game.destroy(true);
_game = undefined;

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

0 comments on commit 8c3a1e8

Please sign in to comment.