diff --git a/spine-ts/spine-phaser/example/assets/phaser.png b/spine-ts/spine-phaser/example/assets/phaser.png new file mode 100644 index 000000000..c824db910 Binary files /dev/null and b/spine-ts/spine-phaser/example/assets/phaser.png differ diff --git a/spine-ts/spine-phaser/example/basic-example.html b/spine-ts/spine-phaser/example/basic-example.html index 0e3b7a75c..dc7f667d2 100644 --- a/spine-ts/spine-phaser/example/basic-example.html +++ b/spine-ts/spine-phaser/example/basic-example.html @@ -36,7 +36,7 @@ function preload () { } function create () { - let spineboy = this.add.spine(400, 300, 'spineboy-data', "spineboy-atlas"); + let spineboy = this.add.spine(400, 500, 'spineboy-data', "spineboy-atlas"); spineboy.scale = 0.5; spineboy.animationState.setAnimation(0, "walk", true); } diff --git a/spine-ts/spine-phaser/example/canvas-test.html b/spine-ts/spine-phaser/example/canvas-test.html new file mode 100644 index 000000000..93be12b27 --- /dev/null +++ b/spine-ts/spine-phaser/example/canvas-test.html @@ -0,0 +1,44 @@ + + + + + + + + + Spine Phaser Example + + +

Canvas test

+ + + \ No newline at end of file diff --git a/spine-ts/spine-phaser/example/depth-test.html b/spine-ts/spine-phaser/example/depth-test.html new file mode 100644 index 000000000..4182b26b1 --- /dev/null +++ b/spine-ts/spine-phaser/example/depth-test.html @@ -0,0 +1,48 @@ + + + + + + + + + Spine Phaser Example + + +

Depth test

+ + + \ No newline at end of file diff --git a/spine-ts/spine-phaser/example/extended-class-test.html b/spine-ts/spine-phaser/example/extended-class-test.html new file mode 100644 index 000000000..8760d5ba2 --- /dev/null +++ b/spine-ts/spine-phaser/example/extended-class-test.html @@ -0,0 +1,103 @@ + + + + + + + + + + Spine Phaser Example + + + +

Extended class

+ + + + \ No newline at end of file diff --git a/spine-ts/spine-phaser/example/index.html b/spine-ts/spine-phaser/example/index.html index 99bbf7a67..72d76b56f 100644 --- a/spine-ts/spine-phaser/example/index.html +++ b/spine-ts/spine-phaser/example/index.html @@ -19,6 +19,10 @@
  • Blend test
  • Camera pipeline test
  • Control bones
  • +
  • Extended class
  • +
  • Canvas test
  • +
  • Depth test
  • +
  • Render to texture test
  • \ No newline at end of file diff --git a/spine-ts/spine-phaser/example/render-to-texture-test.html b/spine-ts/spine-phaser/example/render-to-texture-test.html new file mode 100644 index 000000000..64d331142 --- /dev/null +++ b/spine-ts/spine-phaser/example/render-to-texture-test.html @@ -0,0 +1,58 @@ + + + + + + + + + + Spine Phaser Example + + + +

    Render to texture

    + + + + \ No newline at end of file diff --git a/spine-ts/spine-phaser/src/SpineGameObject.ts b/spine-ts/spine-phaser/src/SpineGameObject.ts index d034922b1..32c60949e 100644 --- a/spine-ts/spine-phaser/src/SpineGameObject.ts +++ b/spine-ts/spine-phaser/src/SpineGameObject.ts @@ -1,8 +1,7 @@ import { SPINE_GAME_OBJECT_TYPE } from "./keys"; import { SpinePlugin } from "./SpinePlugin"; -import { ComputedSizeMixin, DepthMixin, FlipMixin, ScrollFactorMixin, TransformMixin, VisibleMixin } from "./mixins"; +import { ComputedSizeMixin, DepthMixin, FlipMixin, ScrollFactorMixin, TransformMixin, VisibleMixin, AlphaMixin } from "./mixins"; import { AnimationState, AnimationStateData, Bone, MathUtils, Skeleton, Skin, Vector2 } from "@esotericsoftware/spine-core"; -import { Vector3 } from "@esotericsoftware/spine-webgl"; class BaseSpineGameObject extends Phaser.GameObjects.GameObject { constructor (scene: Phaser.Scene, type: string) { @@ -76,7 +75,7 @@ export class SkinsAndAnimationBoundsProvider implements SpineGameObjectBoundsPro } } -export class SpineGameObject extends ComputedSizeMixin(DepthMixin(FlipMixin(ScrollFactorMixin(TransformMixin(VisibleMixin(BaseSpineGameObject)))))) { +export class SpineGameObject extends ComputedSizeMixin(DepthMixin(FlipMixin(ScrollFactorMixin(TransformMixin(VisibleMixin(AlphaMixin(BaseSpineGameObject))))))) { blendMode = -1; skeleton: Skeleton | null = null; animationStateData: AnimationStateData | null = null; @@ -89,7 +88,7 @@ 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()) { super(scene, SPINE_GAME_OBJECT_TYPE); - this.setPosition(x, y); x + this.setPosition(x, y); this.setSkeleton(dataKey, atlasKey); } diff --git a/spine-ts/spine-phaser/src/SpinePlugin.ts b/spine-ts/spine-phaser/src/SpinePlugin.ts index e9520d7eb..49d96770a 100644 --- a/spine-ts/spine-phaser/src/SpinePlugin.ts +++ b/spine-ts/spine-phaser/src/SpinePlugin.ts @@ -106,13 +106,16 @@ export class SpinePlugin extends Phaser.Plugins.ScenePlugin { }; let makeSpineGameObject = function (this: Phaser.GameObjects.GameObjectFactory, config: any, addToScene: boolean) { + let x = config.x ? config.x : 0; + let y = config.y ? config.y : 0; let dataKey = config.dataKey ? config.dataKey : null; let atlasKey = config.atlasKey ? config.atlasKey : null; - let gameObject = new SpineGameObject(this.scene, self, 0, 0, dataKey, atlasKey); + let boundsProvider = config.boundsProvider ? config.boundsProvider : undefined; + let gameObject = new SpineGameObject(this.scene, self, x, y, dataKey, atlasKey, boundsProvider); if (addToScene !== undefined) { config.add = addToScene; } - Phaser.GameObjects.BuildGameObject(this.scene, gameObject, config); + return Phaser.GameObjects.BuildGameObject(this.scene, gameObject, config); } pluginManager.registerGameObject(SPINE_GAME_OBJECT_TYPE, addSpineGameObject, makeSpineGameObject); } diff --git a/spine-ts/spine-phaser/src/mixins.ts b/spine-ts/spine-phaser/src/mixins.ts index 63ab0810d..f4995daad 100644 --- a/spine-ts/spine-phaser/src/mixins.ts +++ b/spine-ts/spine-phaser/src/mixins.ts @@ -31,6 +31,7 @@ export const Flip = components.Flip; export const ScrollFactor = components.ScrollFactor; export const Transform = components.Transform; export const Visible = components.Visible; +export const Alpha = components.Alpha; export interface Type< T, @@ -75,3 +76,5 @@ export const TransformMixin: TransformMixin = createMixin; export const VisibleMixin: VisibleMixin = createMixin(Visible); +type AlphaMixin = Mixin; +export const AlphaMixin: AlphaMixin = createMixin(Alpha); \ No newline at end of file