mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
[phaser] Clean-up, TypeScript example README, non-null SpineGameObject fields.
This commit is contained in:
parent
cc0ee7ce80
commit
2900605300
@ -350,6 +350,10 @@ cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-ts/spine-phaser/example/
|
|||||||
cp -f ../spineboy/export/spineboy-pma.atlas "$ROOT/spine-ts/spine-phaser/example/assets/"
|
cp -f ../spineboy/export/spineboy-pma.atlas "$ROOT/spine-ts/spine-phaser/example/assets/"
|
||||||
cp -f ../spineboy/export/spineboy-pma.png "$ROOT/spine-ts/spine-phaser/example/assets/"
|
cp -f ../spineboy/export/spineboy-pma.png "$ROOT/spine-ts/spine-phaser/example/assets/"
|
||||||
|
|
||||||
|
cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-ts/spine-phaser/example/typescript/assets/"
|
||||||
|
cp -f ../spineboy/export/spineboy-pma.atlas "$ROOT/spine-ts/spine-phaser/example/typescript/assets/"
|
||||||
|
cp -f ../spineboy/export/spineboy-pma.png "$ROOT/spine-ts/spine-phaser/example/typescript/assets/"
|
||||||
|
|
||||||
cp -f ../coin/export/coin-pro.skel "$ROOT/spine-ts/spine-phaser/example/assets/"
|
cp -f ../coin/export/coin-pro.skel "$ROOT/spine-ts/spine-phaser/example/assets/"
|
||||||
cp -f ../coin/export/coin-pma.atlas "$ROOT/spine-ts/spine-phaser/example/assets/"
|
cp -f ../coin/export/coin-pma.atlas "$ROOT/spine-ts/spine-phaser/example/assets/"
|
||||||
cp -f ../coin/export/coin-pma.png "$ROOT/spine-ts/spine-phaser/example/assets/"
|
cp -f ../coin/export/coin-pma.png "$ROOT/spine-ts/spine-phaser/example/assets/"
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
let game = new Phaser.Game(config);
|
let game = new Phaser.Game(config);
|
||||||
|
|
||||||
function preload() {
|
function preload() {
|
||||||
this.load.image('logo', 'assets/phaser.png');
|
this.load.image('logo', 'phaser.png');
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,7 +63,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
preload() {
|
preload() {
|
||||||
this.load.image('logo', 'assets/phaser.png');
|
this.load.image('logo', 'phaser.png');
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
|||||||
6
spine-ts/spine-phaser/example/typescript/README.md
Normal file
6
spine-ts/spine-phaser/example/typescript/README.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# spine-phaser TypeScript
|
||||||
|
Minimal example project using Phaser, spine-phaser, and TypeScript via NPM and [esbuild](https://esbuild.github.io/).
|
||||||
|
|
||||||
|
1. Install dependencies: `npm install`
|
||||||
|
2. Build bundle: `npm run build`
|
||||||
|
3. Development (run server and recompile in watch mode): `npm run dev`
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import {Scene} from "phaser"
|
import {Scene} from "phaser"
|
||||||
import {SpineGameObject, SpineGameObjectBoundsProvider, SpinePlugin} from "@esotericsoftware/spine-phaser"
|
import {SpinePlugin} from "@esotericsoftware/spine-phaser"
|
||||||
|
|
||||||
class SpineDemo extends Scene {
|
class SpineDemo extends Scene {
|
||||||
preload() {
|
preload() {
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
"name": "name",
|
"name": "name",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-phaser": "4.1.*",
|
"@esotericsoftware/spine-phaser": "../../",
|
||||||
"phaser": "3.60.0"
|
"phaser": "3.60.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -370,34 +370,34 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esotericsoftware/spine-canvas": {
|
"node_modules/@esotericsoftware/spine-canvas": {
|
||||||
"version": "4.2.11",
|
"version": "4.1.29",
|
||||||
"resolved": "https://registry.npmjs.org/@esotericsoftware/spine-canvas/-/spine-canvas-4.2.11.tgz",
|
"resolved": "https://registry.npmjs.org/@esotericsoftware/spine-canvas/-/spine-canvas-4.1.29.tgz",
|
||||||
"integrity": "sha512-NEYBSPxAvVaJO2Jtcr/FCYzq6uZprX2BuohA3isq2xn/BckXfZQXLlLT/1+34kK3+gc5XQsMA2YfrHYw35QAMQ==",
|
"integrity": "sha512-X5wbvIPeYRQGvRa30gc2/FNbw6K0IQCn4ByjIB23pEutmXeJJyuRPON0Kn3951Ir5BPUohZoZMYHd2uxyLXTGA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-core": "^4.2.11"
|
"@esotericsoftware/spine-core": "4.1.29"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esotericsoftware/spine-core": {
|
"node_modules/@esotericsoftware/spine-core": {
|
||||||
"version": "4.2.11",
|
"version": "4.1.29",
|
||||||
"resolved": "https://registry.npmjs.org/@esotericsoftware/spine-core/-/spine-core-4.2.11.tgz",
|
"resolved": "https://registry.npmjs.org/@esotericsoftware/spine-core/-/spine-core-4.1.29.tgz",
|
||||||
"integrity": "sha512-yyieou3t6XNYNqbWDdGEkVBg2JAAjLrtrNxGIkweNaH38O4p5Z4pPw2r7BKhCkUEW6+TITYkbNslsGGPU3HMAw=="
|
"integrity": "sha512-Lzgt30MioPRWaco8fyaoVqBOfWO/jsGtRNl+6I1h3sWu9AhpV+/sXYcplSqma3KzWvALh2Q/WFOr5bUSReqINw=="
|
||||||
},
|
},
|
||||||
"node_modules/@esotericsoftware/spine-phaser": {
|
"node_modules/@esotericsoftware/spine-phaser": {
|
||||||
"version": "4.1.28",
|
"version": "4.1.29",
|
||||||
"resolved": "https://registry.npmjs.org/@esotericsoftware/spine-phaser/-/spine-phaser-4.1.28.tgz",
|
"resolved": "https://registry.npmjs.org/@esotericsoftware/spine-phaser/-/spine-phaser-4.1.29.tgz",
|
||||||
"integrity": "sha512-vlDBFeBNLEjxWS4uo24AH4HZeEMfYIDzpsyV8cvnLI5F3E9l+GfHOtdc2to9m1CYOilawZA4zl4oOOCLPgbmWA==",
|
"integrity": "sha512-6vStoBJxnBii9Mk+adX7nygicCwboK49EcIVH+O9C128mH1jc16pb9OeQAT6xeLpFOnE6k+Nre2EXYdQ+eXXYw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-canvas": "^4.1.28",
|
"@esotericsoftware/spine-canvas": "4.1.29",
|
||||||
"@esotericsoftware/spine-core": "^4.1.28",
|
"@esotericsoftware/spine-core": "4.1.29",
|
||||||
"@esotericsoftware/spine-webgl": "^4.1.28"
|
"@esotericsoftware/spine-webgl": "4.1.29"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esotericsoftware/spine-webgl": {
|
"node_modules/@esotericsoftware/spine-webgl": {
|
||||||
"version": "4.2.11",
|
"version": "4.1.29",
|
||||||
"resolved": "https://registry.npmjs.org/@esotericsoftware/spine-webgl/-/spine-webgl-4.2.11.tgz",
|
"resolved": "https://registry.npmjs.org/@esotericsoftware/spine-webgl/-/spine-webgl-4.1.29.tgz",
|
||||||
"integrity": "sha512-DCk+Qp4QxzA3PCYpxtVxt1cChnDhs9AjvbzVtHkHE7nKyRnoYjH7JDghuyVvOEI8YJZS29vDD0rD7i22ne9QXg==",
|
"integrity": "sha512-sucAXTO0Hp5BR4DqkQTkA+gKI62AtCoSmz1Ld9akowG/x1+XYLVJ9GEbYLsUEUyoZOAP7aWa/HzGDSi/sHRs0w==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-core": "^4.2.11"
|
"@esotericsoftware/spine-core": "4.1.29"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/accepts": {
|
"node_modules/accepts": {
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
"dev": "npx concurrently \"npx live-server --no-browser\" \"npm run build -- --watch\""
|
"dev": "npx concurrently \"npx live-server --no-browser\" \"npm run build -- --watch\""
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@esotericsoftware/spine-phaser": "4.1.*",
|
"@esotericsoftware/spine-phaser": "../../",
|
||||||
"phaser": "3.60.0"
|
"phaser": "3.60.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@ -77,9 +77,9 @@ export class SkinsAndAnimationBoundsProvider implements SpineGameObjectBoundsPro
|
|||||||
|
|
||||||
export class SpineGameObject extends ComputedSizeMixin(DepthMixin(FlipMixin(ScrollFactorMixin(TransformMixin(VisibleMixin(AlphaMixin(BaseSpineGameObject))))))) {
|
export class SpineGameObject extends ComputedSizeMixin(DepthMixin(FlipMixin(ScrollFactorMixin(TransformMixin(VisibleMixin(AlphaMixin(BaseSpineGameObject))))))) {
|
||||||
blendMode = -1;
|
blendMode = -1;
|
||||||
skeleton: Skeleton | null = null;
|
skeleton: Skeleton;
|
||||||
animationStateData: AnimationStateData | null = null;
|
animationStateData: AnimationStateData;
|
||||||
animationState: AnimationState | null = null;
|
animationState: AnimationState;
|
||||||
private premultipliedAlpha = false;
|
private premultipliedAlpha = false;
|
||||||
private _displayOriginX = 0;
|
private _displayOriginX = 0;
|
||||||
private _displayOriginY = 0;
|
private _displayOriginY = 0;
|
||||||
@ -89,21 +89,12 @@ export class SpineGameObject extends ComputedSizeMixin(DepthMixin(FlipMixin(Scro
|
|||||||
constructor (scene: Phaser.Scene, private plugin: SpinePlugin, x: number, y: number, dataKey: string, atlasKey: string, public boundsProvider: SpineGameObjectBoundsProvider = new SetupPoseBoundsProvider()) {
|
constructor (scene: Phaser.Scene, private plugin: SpinePlugin, x: number, y: number, dataKey: string, atlasKey: string, public boundsProvider: SpineGameObjectBoundsProvider = new SetupPoseBoundsProvider()) {
|
||||||
super(scene, SPINE_GAME_OBJECT_TYPE);
|
super(scene, SPINE_GAME_OBJECT_TYPE);
|
||||||
this.setPosition(x, y);
|
this.setPosition(x, y);
|
||||||
this.setSkeleton(dataKey, atlasKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
setSkeleton (dataKey: string, atlasKey: string) {
|
this.premultipliedAlpha = this.plugin.isAtlasPremultiplied(atlasKey);
|
||||||
if (dataKey && atlasKey) {
|
this.skeleton = this.plugin.createSkeleton(dataKey, atlasKey);
|
||||||
this.premultipliedAlpha = this.plugin.isAtlasPremultiplied(atlasKey);
|
this.animationStateData = new AnimationStateData(this.skeleton.data);
|
||||||
this.skeleton = this.plugin.createSkeleton(dataKey, atlasKey);
|
this.animationState = new AnimationState(this.animationStateData);
|
||||||
this.animationStateData = new AnimationStateData(this.skeleton.data);
|
this.updateSize();
|
||||||
this.animationState = new AnimationState(this.animationStateData);
|
|
||||||
this.updateSize();
|
|
||||||
} else {
|
|
||||||
this.skeleton = null;
|
|
||||||
this.animationStateData = null;
|
|
||||||
this.animationState = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public get displayOriginX () {
|
public get displayOriginX () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user