[phaser] Improve TypeScript example.

This commit is contained in:
Mario Zechner 2023-04-26 11:16:13 +02:00
parent 43caf7563b
commit bf3f70379f
2 changed files with 7 additions and 8 deletions

View File

@ -14,7 +14,7 @@
<h1>Basic example</h1> <h1>Basic example</h1>
</body> </body>
<script> <script>
class BasicScene extends Phaser.Scene { class BasicExample extends Phaser.Scene {
preload() { preload() {
this.load.spineBinary("spineboy-data", "assets/spineboy-pro.skel"); this.load.spineBinary("spineboy-data", "assets/spineboy-pro.skel");
this.load.spineAtlas("spineboy-atlas", "assets/spineboy-pma.atlas"); this.load.spineAtlas("spineboy-atlas", "assets/spineboy-pma.atlas");
@ -37,7 +37,7 @@
width: 800, width: 800,
height: 600, height: 600,
type: Phaser.WEBGL, type: Phaser.WEBGL,
scene: [BasicScene], scene: [BasicExample],
plugins: { plugins: {
scene: [ scene: [
{ key: "spine.SpinePlugin", plugin: spine.SpinePlugin, mapping: "spine" } { key: "spine.SpinePlugin", plugin: spine.SpinePlugin, mapping: "spine" }

View File

@ -1,7 +1,7 @@
import {Scene} from "phaser" import * as Phaser from "phaser"
import {SpinePlugin} from "@esotericsoftware/spine-phaser" import * as spine from "@esotericsoftware/spine-phaser"
class SpineDemo extends Scene { class SpineDemo extends Phaser.Scene {
preload() { preload() {
this.load.spineBinary("spineboy-data", "assets/spineboy-pro.skel"); this.load.spineBinary("spineboy-data", "assets/spineboy-pro.skel");
this.load.spineAtlas("spineboy-atlas", "assets/spineboy-pma.atlas"); this.load.spineAtlas("spineboy-atlas", "assets/spineboy-pma.atlas");
@ -9,7 +9,6 @@ class SpineDemo extends Scene {
create() { create() {
const spineboy = this.add.spine(400, 500, 'spineboy-data', "spineboy-atlas"); const spineboy = this.add.spine(400, 500, 'spineboy-data', "spineboy-atlas");
this.make
spineboy.scale = 0.5; spineboy.scale = 0.5;
spineboy.animationState.setAnimation(0, "walk", true); spineboy.animationState.setAnimation(0, "walk", true);
} }
@ -22,7 +21,7 @@ const config = {
scene: [SpineDemo], scene: [SpineDemo],
plugins: { plugins: {
scene: [ scene: [
{ key: "spine.SpinePlugin", plugin: SpinePlugin, mapping: "spine" } { key: "spine.SpinePlugin", plugin: spine.SpinePlugin, mapping: "spine" }
] ]
} }
}; };