Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b2a9e80

Browse filesBrowse files
committed
Update App.jsx
1 parent 6676993 commit b2a9e80
Copy full SHA for b2a9e80

File tree

Expand file treeCollapse file tree

1 file changed

+8
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-6
lines changed

‎src/App.jsx

Copy file name to clipboardExpand all lines: src/App.jsx
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { PhaserGame } from './game/PhaserGame';
66
function App ()
77
{
88
// The sprite can only be moved in the MainMenu Scene
9-
const [canMoveLogo, setCanMoveLogo] = useState(true);
9+
const [canMoveSprite, setCanMoveSprite] = useState(true);
1010

1111
// References to the PhaserGame component (game and scene are exposed)
1212
const phaserRef = useRef();
13-
const [logoPosition, setLogoPosition] = useState({ x: 0, y: 0 });
13+
const [spritePosition, setSpritePosition] = useState({ x: 0, y: 0 });
1414

1515
const changeScene = () => {
1616

@@ -31,7 +31,7 @@ function App ()
3131
// Get the update logo position
3232
scene.moveLogo(({ x, y }) => {
3333

34-
setLogoPosition({ x, y });
34+
setSpritePosition({ x, y });
3535

3636
});
3737
}
@@ -65,7 +65,9 @@ function App ()
6565

6666
// Event emitted from the PhaserGame component
6767
const currentScene = (scene) => {
68-
setCanMoveLogo(scene.scene.key !== 'MainMenu');
68+
69+
setCanMoveSprite(scene.scene.key !== 'MainMenu');
70+
6971
}
7072

7173
return (
@@ -76,10 +78,10 @@ function App ()
7678
<button className="button" onClick={changeScene}>Change Scene</button>
7779
</div>
7880
<div>
79-
<button disabled={canMoveLogo} className="button" onClick={moveSprite}>Toggle Movement</button>
81+
<button disabled={canMoveSprite} className="button" onClick={moveSprite}>Toggle Movement</button>
8082
</div>
8183
<div className="spritePosition">Sprite Position:
82-
<pre>{`{\n x: ${logoPosition.x}\n y: ${logoPosition.y}\n}`}</pre>
84+
<pre>{`{\n x: ${spritePosition.x}\n y: ${spritePosition.y}\n}`}</pre>
8385
</div>
8486
<div>
8587
<button className="button" onClick={addSprite}>Add New Sprite</button>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.