From 413a148a319aae883c9099650eea9c6175bb687d Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 26 Aug 2020 00:00:00 +0100 Subject: [PATCH] Updated docs and Creator param --- plugins/spine/src/SpinePlugin.js | 13 +++++++-- plugins/spine/src/container/SpineContainer.js | 29 +++++++++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/plugins/spine/src/SpinePlugin.js b/plugins/spine/src/SpinePlugin.js index d4afb9ef7..12a7f9a6c 100644 --- a/plugins/spine/src/SpinePlugin.js +++ b/plugins/spine/src/SpinePlugin.js @@ -76,10 +76,15 @@ var NOOP = require('../../../src/utils/NOOP'); * this.load.spine('stretchyman', 'stretchyman-pro.json', [ 'stretchyman-pma.atlas' ], true); * ``` * - * It also installs a Game Object Factory method, allowing you to create Spine Game Objects: + * It also installs two Game Object Factory methods, allowing you to create Spine Game Objects + * and Spine Containers: * * ```javascript - * this.add.spine(512, 650, 'stretchyman') + * const man = this.add.spine(512, 650, 'stretchyman'); + * + * const container = this.add.spineContainer(); + * + * container.add(man); * ``` * * The first argument is the key which you used when importing the Spine data. There are lots of @@ -379,7 +384,7 @@ var SpinePlugin = new Class({ pluginManager.registerFileType('spine', this.spineFileCallback, scene); pluginManager.registerGameObject('spine', add, make); - pluginManager.registerGameObject('spinecontainer', addContainer, makeContainer); + pluginManager.registerGameObject('spineContainer', addContainer, makeContainer); }, /** @@ -1096,6 +1101,7 @@ var SpinePlugin = new Class({ } this.pluginManager.removeGameObject('spine', true, true); + this.pluginManager.removeGameObject('spineContainer', true, true); this.pluginManager = null; this.game = null; @@ -1114,6 +1120,7 @@ var SpinePlugin = new Class({ }); SpinePlugin.SpineGameObject = SpineGameObject; +SpinePlugin.SpineContainer = SpineContainer; /** * Creates a new Spine Game Object and adds it to the Scene. diff --git a/plugins/spine/src/container/SpineContainer.js b/plugins/spine/src/container/SpineContainer.js index aaa17292f..27ca4a1d4 100644 --- a/plugins/spine/src/container/SpineContainer.js +++ b/plugins/spine/src/container/SpineContainer.js @@ -13,8 +13,8 @@ var SpineContainerRender = require('./SpineContainerRender'); * A Spine Container is a special kind of Container created specifically for Spine Game Objects. * * You have all of the same features of a standard Container, but the rendering functions are optimized specifically - * for Spine Game Objects. You cannot mix and match Spine Game Objects with regular Game Objects inside of this - * type of Container, however. + * for Spine Game Objects. You must only add ever Spine Game Objects to this type of Container. Although Phaser will + * not prevent you from adding other types, they will not render and are likely to throw runtime errors. * * To create one in a Scene, use the factory methods: * @@ -28,7 +28,7 @@ var SpineContainerRender = require('./SpineContainerRender'); * this.make.spinecontainer(); * ``` * - * See the Container documentation for further details. + * See the Container documentation for further details about what Containers can do. * * @class SpineContainer * @extends Phaser.GameObjects.Container @@ -61,11 +61,30 @@ var SpineContainer = new Class({ /** * A reference to the Spine Plugin. * - * @name SpineGameObject#plugin + * @name SpineContainer#plugin * @type {SpinePlugin} - * @since 3.19.0 + * @since 3.50.0 */ this.plugin = plugin; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method SpineContainer#preDestroy + * @protected + * @since 3.50.0 + */ + preDestroy: function () + { + this.removeAll(!!this.exclusive); + + this.localTransform.destroy(); + this.tempTransformMatrix.destroy(); + + this.list = []; + this._displayList = null; + this.plugin = null; } });