Skip to content

Commit 60ac454

Browse files
committed
update bg
1 parent 384cfdb commit 60ac454

File tree

4 files changed

+21
-28
lines changed

4 files changed

+21
-28
lines changed

public/assets/bg.png

-6.63 KB
Loading

src/App.tsx

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import { MainMenu } from './game/scenes/MainMenu';
55
function App()
66
{
77
// The sprite can only be moved in the MainMenu Scene
8-
const [canMoveSprite, setCanMoveSprite] = useState(true);
8+
const [, setCanMoveSprite] = useState(true);
99

1010
// References to the PhaserGame component (game and scene are exposed)
1111
const phaserRef = useRef<IRefPhaserGame | null>(null);
12-
const [spritePosition, setSpritePosition] = useState({ x: 0, y: 0 });
12+
const [spritePosition] = useState({ x: 0, y: 0 });
1313

1414
const changeScene = () => {
1515

@@ -24,26 +24,6 @@ function App()
2424
}
2525
}
2626

27-
const moveSprite = () => {
28-
29-
if(phaserRef.current)
30-
{
31-
32-
const scene = phaserRef.current.scene as MainMenu;
33-
34-
if (scene && scene.scene.key === 'MainMenu')
35-
{
36-
// Get the update logo position
37-
scene.moveLogo(({ x, y }) => {
38-
39-
setSpritePosition({ x, y });
40-
41-
});
42-
}
43-
}
44-
45-
}
46-
4727
const addSprite = () => {
4828

4929
if (phaserRef.current)
@@ -93,16 +73,24 @@ function App()
9373
window.open("https://github.com/zktx-io/phaserjs-template-react-ts", "_blank", "noopener,noreferrer");
9474
};
9575

76+
const handleClick_4 = () => {
77+
window.open("https://phaser.io/", "_blank", "noopener,noreferrer");
78+
};
79+
9680
return (
9781
<div id="app">
9882
<PhaserGame ref={phaserRef} currentActiveScene={currentScene} />
9983
<div>
10084
<div>
10185
<button className="button" onClick={changeScene}>Change Scene</button>
10286
</div>
103-
<div>
104-
<button disabled={canMoveSprite} className="button" onClick={moveSprite}>Toggle Movement</button>
105-
</div>
87+
{
88+
/*
89+
<div>
90+
<button disabled={canMoveSprite} className="button" onClick={moveSprite}>Toggle Movement</button>
91+
</div>
92+
*/
93+
}
10694
<div className="spritePosition">Sprite Position:
10795
<pre>{`{\n x: ${spritePosition.x}\n y: ${spritePosition.y}\n}`}</pre>
10896
</div>
@@ -118,6 +106,9 @@ function App()
118106
<div>
119107
<button className="button" onClick={handleClick_3}>example github</button>
120108
</div>
109+
<div>
110+
<button className="button" onClick={handleClick_4}>Phaser</button>
111+
</div>
121112
</div>
122113
</div>
123114
)

src/game/scenes/MainMenu.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { EventBus } from '../EventBus';
55
export class MainMenu extends Scene
66
{
77
background: GameObjects.Image;
8-
logo: GameObjects.Image;
8+
// logo: GameObjects.Image;
99
title: GameObjects.Text;
1010
logoTween: Phaser.Tweens.Tween | null;
1111

@@ -18,7 +18,7 @@ export class MainMenu extends Scene
1818
{
1919
this.background = this.add.image(512, 384, 'background');
2020

21-
this.logo = this.add.image(512, 300, 'logo').setDepth(100);
21+
// this.logo = this.add.image(512, 300, 'logo').setDepth(100);
2222

2323
this.title = this.add.text(512, 460, 'Main Menu', {
2424
fontFamily: 'Arial Black', fontSize: 38, color: '#ffffff',
@@ -40,6 +40,7 @@ export class MainMenu extends Scene
4040
this.scene.start('Game');
4141
}
4242

43+
/*
4344
moveLogo (vueCallback: ({ x, y }: { x: number, y: number }) => void)
4445
{
4546
if (this.logoTween)
@@ -73,4 +74,5 @@ export class MainMenu extends Scene
7374
});
7475
}
7576
}
77+
*/
7678
}

src/game/scenes/Preloader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class Preloader extends Scene
3232
// Load the assets for the game - Replace with your own assets
3333
this.load.setPath('assets');
3434

35-
this.load.image('logo', 'logo.png');
35+
// this.load.image('logo', 'logo.png');
3636
this.load.image('star', 'star.png');
3737
this.load.image('sui', 'sui.png');
3838
this.load.image('walrus', 'walrus.png');

0 commit comments

Comments
 (0)