Spaces:
Sleeping
Sleeping
wip
Browse files- .dockerignore +57 -0
- src/App.tsx +11 -11
.dockerignore
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Dependencies
|
| 2 |
+
node_modules
|
| 3 |
+
npm-debug.log
|
| 4 |
+
yarn-debug.log
|
| 5 |
+
yarn-error.log
|
| 6 |
+
|
| 7 |
+
# Next.js
|
| 8 |
+
.next
|
| 9 |
+
out
|
| 10 |
+
|
| 11 |
+
# Testing
|
| 12 |
+
coverage
|
| 13 |
+
|
| 14 |
+
# Production
|
| 15 |
+
build
|
| 16 |
+
dist
|
| 17 |
+
|
| 18 |
+
# Misc
|
| 19 |
+
.DS_Store
|
| 20 |
+
*.pem
|
| 21 |
+
.env
|
| 22 |
+
.env.local
|
| 23 |
+
.env.development.local
|
| 24 |
+
.env.test.local
|
| 25 |
+
.env.production.local
|
| 26 |
+
|
| 27 |
+
# Debug
|
| 28 |
+
npm-debug.log*
|
| 29 |
+
yarn-debug.log*
|
| 30 |
+
yarn-error.log*
|
| 31 |
+
|
| 32 |
+
# IDE
|
| 33 |
+
.idea
|
| 34 |
+
.vscode
|
| 35 |
+
*.suo
|
| 36 |
+
*.ntvs*
|
| 37 |
+
*.njsproj
|
| 38 |
+
*.sln
|
| 39 |
+
*.sw?
|
| 40 |
+
|
| 41 |
+
# Git
|
| 42 |
+
.git
|
| 43 |
+
.gitignore
|
| 44 |
+
|
| 45 |
+
# Docker
|
| 46 |
+
Dockerfile
|
| 47 |
+
.dockerignore
|
| 48 |
+
|
| 49 |
+
# TypeScript
|
| 50 |
+
*.tsbuildinfo
|
| 51 |
+
|
| 52 |
+
# Logs
|
| 53 |
+
logs
|
| 54 |
+
*.log
|
| 55 |
+
|
| 56 |
+
# Cache
|
| 57 |
+
.cache
|
src/App.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import { useRef, useState } from 'react';
|
| 2 |
-
import { IRefPhaserGame
|
| 3 |
import { MainMenu } from './game/scenes/MainMenu';
|
| 4 |
|
| 5 |
function App()
|
|
@@ -8,15 +8,16 @@ function App()
|
|
| 8 |
const [canMoveSprite, setCanMoveSprite] = useState(true);
|
| 9 |
|
| 10 |
// References to the PhaserGame component (game and scene are exposed)
|
| 11 |
-
const phaserRef = useRef<IRefPhaserGame
|
| 12 |
const [spritePosition, setSpritePosition] = useState({ x: 0, y: 0 });
|
|
|
|
| 13 |
|
| 14 |
const changeScene = () => {
|
| 15 |
|
| 16 |
if(phaserRef.current)
|
| 17 |
-
{
|
| 18 |
const scene = phaserRef.current.scene as MainMenu;
|
| 19 |
-
|
| 20 |
if (scene)
|
| 21 |
{
|
| 22 |
scene.changeScene();
|
|
@@ -55,10 +56,10 @@ function App()
|
|
| 55 |
// Add more stars
|
| 56 |
const x = Phaser.Math.Between(64, scene.scale.width - 64);
|
| 57 |
const y = Phaser.Math.Between(64, scene.scale.height - 64);
|
| 58 |
-
|
| 59 |
// `add.sprite` is a Phaser GameObjectFactory method and it returns a Sprite Game Object instance
|
| 60 |
const star = scene.add.sprite(x, y, 'star');
|
| 61 |
-
|
| 62 |
// ... which you can then act upon. Here we create a Phaser Tween to fade the star sprite in and out.
|
| 63 |
// You could, of course, do this from within the Phaser Scene code, but this is just an example
|
| 64 |
// showing that Phaser objects and systems can be acted upon from outside of Phaser itself.
|
|
@@ -74,15 +75,14 @@ function App()
|
|
| 74 |
}
|
| 75 |
|
| 76 |
// Event emitted from the PhaserGame component
|
| 77 |
-
const
|
| 78 |
-
|
| 79 |
setCanMoveSprite(scene.scene.key !== 'MainMenu');
|
| 80 |
-
|
| 81 |
-
}
|
| 82 |
|
| 83 |
return (
|
| 84 |
<div id="app">
|
| 85 |
-
<PhaserGame
|
| 86 |
<div>
|
| 87 |
<div>
|
| 88 |
<button className="button" onClick={changeScene}>Change Scene</button>
|
|
|
|
| 1 |
import { useRef, useState } from 'react';
|
| 2 |
+
import PhaserGame, { IRefPhaserGame } from './game/PhaserGame';
|
| 3 |
import { MainMenu } from './game/scenes/MainMenu';
|
| 4 |
|
| 5 |
function App()
|
|
|
|
| 8 |
const [canMoveSprite, setCanMoveSprite] = useState(true);
|
| 9 |
|
| 10 |
// References to the PhaserGame component (game and scene are exposed)
|
| 11 |
+
const phaserRef = useRef<IRefPhaserGame>();
|
| 12 |
const [spritePosition, setSpritePosition] = useState({ x: 0, y: 0 });
|
| 13 |
+
const [currentScene, setCurrentScene] = useState<Phaser.Scene | null>(null);
|
| 14 |
|
| 15 |
const changeScene = () => {
|
| 16 |
|
| 17 |
if(phaserRef.current)
|
| 18 |
+
{
|
| 19 |
const scene = phaserRef.current.scene as MainMenu;
|
| 20 |
+
|
| 21 |
if (scene)
|
| 22 |
{
|
| 23 |
scene.changeScene();
|
|
|
|
| 56 |
// Add more stars
|
| 57 |
const x = Phaser.Math.Between(64, scene.scale.width - 64);
|
| 58 |
const y = Phaser.Math.Between(64, scene.scale.height - 64);
|
| 59 |
+
|
| 60 |
// `add.sprite` is a Phaser GameObjectFactory method and it returns a Sprite Game Object instance
|
| 61 |
const star = scene.add.sprite(x, y, 'star');
|
| 62 |
+
|
| 63 |
// ... which you can then act upon. Here we create a Phaser Tween to fade the star sprite in and out.
|
| 64 |
// You could, of course, do this from within the Phaser Scene code, but this is just an example
|
| 65 |
// showing that Phaser objects and systems can be acted upon from outside of Phaser itself.
|
|
|
|
| 75 |
}
|
| 76 |
|
| 77 |
// Event emitted from the PhaserGame component
|
| 78 |
+
const onCurrentActiveScene = (scene: Phaser.Scene) => {
|
| 79 |
+
setCurrentScene(scene);
|
| 80 |
setCanMoveSprite(scene.scene.key !== 'MainMenu');
|
| 81 |
+
};
|
|
|
|
| 82 |
|
| 83 |
return (
|
| 84 |
<div id="app">
|
| 85 |
+
<PhaserGame currentActiveScene={onCurrentActiveScene} />
|
| 86 |
<div>
|
| 87 |
<div>
|
| 88 |
<button className="button" onClick={changeScene}>Change Scene</button>
|