Skip to content

Commit

Permalink
update bg
Browse files Browse the repository at this point in the history
  • Loading branch information
daoauth committed Feb 2, 2025
1 parent 384cfdb commit 60ac454
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 28 deletions.
Binary file modified public/assets/bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 16 additions & 25 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { MainMenu } from './game/scenes/MainMenu';
function App()
{
// The sprite can only be moved in the MainMenu Scene
const [canMoveSprite, setCanMoveSprite] = useState(true);
const [, setCanMoveSprite] = useState(true);

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

const changeScene = () => {

Expand All @@ -24,26 +24,6 @@ function App()
}
}

const moveSprite = () => {

if(phaserRef.current)
{

const scene = phaserRef.current.scene as MainMenu;

if (scene && scene.scene.key === 'MainMenu')
{
// Get the update logo position
scene.moveLogo(({ x, y }) => {

setSpritePosition({ x, y });

});
}
}

}

const addSprite = () => {

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

const handleClick_4 = () => {
window.open("https://phaser.io/", "_blank", "noopener,noreferrer");
};

return (
<div id="app">
<PhaserGame ref={phaserRef} currentActiveScene={currentScene} />
<div>
<div>
<button className="button" onClick={changeScene}>Change Scene</button>
</div>
<div>
<button disabled={canMoveSprite} className="button" onClick={moveSprite}>Toggle Movement</button>
</div>
{
/*
<div>
<button disabled={canMoveSprite} className="button" onClick={moveSprite}>Toggle Movement</button>
</div>
*/
}
<div className="spritePosition">Sprite Position:
<pre>{`{\n x: ${spritePosition.x}\n y: ${spritePosition.y}\n}`}</pre>
</div>
Expand All @@ -118,6 +106,9 @@ function App()
<div>
<button className="button" onClick={handleClick_3}>example github</button>
</div>
<div>
<button className="button" onClick={handleClick_4}>Phaser</button>
</div>
</div>
</div>
)
Expand Down
6 changes: 4 additions & 2 deletions src/game/scenes/MainMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EventBus } from '../EventBus';
export class MainMenu extends Scene
{
background: GameObjects.Image;
logo: GameObjects.Image;
// logo: GameObjects.Image;
title: GameObjects.Text;
logoTween: Phaser.Tweens.Tween | null;

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

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

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

/*
moveLogo (vueCallback: ({ x, y }: { x: number, y: number }) => void)
{
if (this.logoTween)
Expand Down Expand Up @@ -73,4 +74,5 @@ export class MainMenu extends Scene
});
}
}
*/
}
2 changes: 1 addition & 1 deletion src/game/scenes/Preloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class Preloader extends Scene
// Load the assets for the game - Replace with your own assets
this.load.setPath('assets');

this.load.image('logo', 'logo.png');
// this.load.image('logo', 'logo.png');
this.load.image('star', 'star.png');
this.load.image('sui', 'sui.png');
this.load.image('walrus', 'walrus.png');
Expand Down

0 comments on commit 60ac454

Please sign in to comment.