vue-phaserjs 4.3.3 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -26
- package/dist/index.d.ts +1249 -1000
- package/dist/index.js +601 -286
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -5,59 +5,68 @@
|
|
|
5
5
|
[![NPM downloads][badge-npm-downloads]][url-npm]
|
|
6
6
|
[![NPM Unpacked Size (with version)][badge-npm-unpacked-size]][url-npm]
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
This package integrates the [Phaser](https://phaser.io) game engine with Vue. It provides Vue components and composables that bridge Phaser scenes, game objects and Pinia state to the Vue component lifecycle.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Design notes live in [the specs](https://github.com/Esposter/Esposter/tree/main/openspec/specs/vue-phaserjs).
|
|
11
11
|
|
|
12
12
|
## Table of Contents
|
|
13
13
|
|
|
14
14
|
- 🚀 [Getting Started](#getting-started)
|
|
15
|
-
-
|
|
15
|
+
- 🧩 [Key Exports](#key-exports)
|
|
16
16
|
- ⚖️ [License](#license)
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
20
|
## <a name="getting-started">🚀 Getting Started</a>
|
|
21
21
|
|
|
22
|
+
1. Install the packages.
|
|
23
|
+
|
|
22
24
|
```bash
|
|
23
25
|
pnpm i vue-phaserjs @esposter/shared parse-tmx vue phaser phaser4-rex-plugins pinia
|
|
24
26
|
```
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- [`phaser.d.ts`](https://github.com/Esposter/Esposter/blob/main/apps/web/app/types/phaser.d.ts) — narrows scene key types
|
|
29
|
-
- [`vue-phaserjs.d.ts`](https://github.com/Esposter/Esposter/blob/main/apps/web/app/types/vue-phaserjs.d.ts) — provides custom plugin types
|
|
30
|
-
|
|
31
|
-
## <a name="documentation">📖 Documentation</a>
|
|
32
|
-
|
|
33
|
-
We highly recommend you take a look at the [documentation](https://github.com/Esposter/Esposter/tree/main/openspec/specs/vue-phaserjs) to level up.
|
|
28
|
+
Check: the install ends with no peer or version conflict, and `package.json` lists `vue-phaserjs`.
|
|
34
29
|
|
|
35
|
-
|
|
30
|
+
2. Add these type declaration files. The editor shows intellisense for scene keys and custom plugins.
|
|
31
|
+
- [`phaser.d.ts`](https://github.com/Esposter/Esposter/blob/main/apps/web/app/types/phaser.d.ts) narrows the scene key types.
|
|
32
|
+
- [`vue-phaserjs.d.ts`](https://github.com/Esposter/Esposter/blob/main/apps/web/app/types/vue-phaserjs.d.ts) provides the custom plugin types.
|
|
36
33
|
|
|
37
|
-
|
|
34
|
+
3. Create a component from this code. The page shows the text `Hello`.
|
|
38
35
|
|
|
39
|
-
|
|
36
|
+
```vue
|
|
37
|
+
<script setup lang="ts">
|
|
38
|
+
import { Game, Scene, Text } from "vue-phaserjs";
|
|
39
|
+
</script>
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
<template>
|
|
42
|
+
<Game :configuration="{ height: 600, width: 800 }">
|
|
43
|
+
<Scene autoStart sceneKey="menu">
|
|
44
|
+
<Text :configuration="{ style: { fontSize: '32px' }, text: 'Hello', x: 400, y: 300 }" />
|
|
45
|
+
</Scene>
|
|
46
|
+
</Game>
|
|
47
|
+
</template>
|
|
48
|
+
```
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
For a complete example, see [the dungeons page](https://github.com/Esposter/Esposter/blob/main/apps/web/app/pages/dungeons.vue). It embeds a Phaser game in a Nuxt/Vue page with Pinia-driven state.
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
## <a name="key-exports">🧩 Key Exports</a>
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
| Export | Kind | Purpose |
|
|
55
|
+
| ------------------------------------------------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------- |
|
|
56
|
+
| `Game` | component | Starts a Phaser game in its element. Renders its slot once the game is ready. |
|
|
57
|
+
| `onCreate`, `onInit`, `onNextTick`, `onPreload`, `onShutdown`, `onUpdate` | function | Runs a callback at one stage of a scene's lifecycle. Returns the function that removes the callback. |
|
|
58
|
+
| `Scene` | component | Adds a Phaser scene. Starts it when `autoStart` is set. Renders its children while it is active. |
|
|
59
|
+
| `Sprite` | component | A sprite drawn in the enclosing scene from its configuration |
|
|
60
|
+
| `useAnimations` | composable | Creates a scene's animation frames. Removes them on shutdown or unmount. |
|
|
61
|
+
| `useGame` | composable | The Phaser game in the store. Throws until a Game component has created it. |
|
|
62
|
+
| `useTween` | composable | Sets a tween on a ref. Clears the ref when the tween completes. |
|
|
56
63
|
|
|
57
64
|
## <a name="license">⚖️ License</a>
|
|
58
65
|
|
|
59
66
|
This project is licensed under the [Apache-2.0 license](https://github.com/Esposter/Esposter/blob/main/LICENSE).
|
|
60
67
|
|
|
68
|
+
Inspired by [phavuer](https://github.com/laineus/phavuer).
|
|
69
|
+
|
|
61
70
|
[badge-license]: https://img.shields.io/github/license/Esposter/Esposter.svg?color=blue
|
|
62
71
|
[url-license]: https://github.com/Esposter/Esposter/blob/main/LICENSE
|
|
63
72
|
[badge-npm-version]: https://img.shields.io/npm/v/vue-phaserjs/latest?color=brightgreen
|