Skip to content

Commit

Permalink
在路由跳转之前结束游戏
Browse files Browse the repository at this point in the history
  • Loading branch information
sqwwwok committed May 15, 2020
1 parent b48d5db commit bd7d796
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion pages/play.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export default {
}
this.isSettingOpen = !this.isSettingOpen;
}else if(icon==='exit'){
this.changeGameState('exit');
this.$router.push('/');
}else{
this.changeGameState(icon);
Expand All @@ -108,6 +107,10 @@ export default {
}
this.handleIconClicked('setting');
}
},
beforeDestroy(){
this.changeGameState('exit');
console.log('beforeDestory');
}
}
</script>
Expand Down
15 changes: 12 additions & 3 deletions scripts/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,22 @@ function main(canvasEl, {playerImage, obsImage, groundImage, bgImage}, connector
function gameController (state) {
switch (state) {
case 'start':
if(__game.state==='readying') __game.state = 'start';
if(__game.state==='readying'){
startGame();
__game.state = 'running';
}
break;
case 'pause':
if(__game.state==='running') __game.state = 'pause';
if(__game.state==='running'){
pauseGame();
__game.state = 'waiting';
}
break;
case 'continue':
if(__game.state==='waiting') __game.state = 'countinue';
if(__game.state==='waiting'){
restartGame();
__game.state = 'running';
}
break;
case 'replay':
overGame();
Expand Down

1 comment on commit bd7d796

@vercel
Copy link

@vercel vercel bot commented on bd7d796 Aug 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.