Skip to content

Commit

Permalink
feat(scenes): add Lose
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Apr 26, 2024
1 parent 95128c2 commit 0c22172
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/constants/key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const image = {

const scene = {
boot: 'boot',
lose: 'lose',
main: 'main',
menu: 'menu',
win: 'win',
Expand Down
42 changes: 42 additions & 0 deletions src/scenes/Lose.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Scene } from 'phaser';
import { render, Text } from 'phaser-jsx';

import { Button } from '../components';
import { key } from '../constants';

export class Lose extends Scene {
constructor() {
super(key.scene.lose);
}

create() {
const { centerX, centerY } = this.cameras.main;

render(
<>
<Text
text="You Lose!"
x={centerX}
y={centerY - 100}
style={{
color: 'white',
fontSize: '36px',
}}
originX={0.5}
originY={0.5}
/>

<Button
center
fixed
x={centerX}
y={centerY + 100}
onClick={() => this.scene.start(key.scene.main, { level: 0 })}
>
Restart
</Button>
</>,
this,
);
}
}
4 changes: 4 additions & 0 deletions src/scenes/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ export class Main extends Phaser.Scene {
0,
1,
);

if (this.vignette.radius === 0) {
this.scene.start(key.scene.lose);
}
},
callbackScope: this,
loop: true,
Expand Down
1 change: 1 addition & 0 deletions src/scenes/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './Boot';
export * from './Lose';
export * from './Main';
export * from './Menu';
export * from './Win';

0 comments on commit 0c22172

Please sign in to comment.