mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 14:08:28 +00:00
Added more jsdocs
This commit is contained in:
parent
6c1d59ec2e
commit
b3615b77df
2 changed files with 95 additions and 1 deletions
|
@ -20,6 +20,46 @@ var SpineGameObject = require('./gameobject/SpineGameObject');
|
|||
* All rendering and object creation is handled via the official Spine Runtimes. This version of the plugin
|
||||
* uses the Spine 3.7 runtimes. Files created in a more recent version of Spine may not work as a result.
|
||||
*
|
||||
* You can find more details about Spine at http://esotericsoftware.com/.
|
||||
*
|
||||
* Please note that you require a Spine license in order to use Spine Runtimes in your games.
|
||||
*
|
||||
* You can install this plugin into your Phaser game by either importing it, if you're using ES6:
|
||||
*
|
||||
* ```javascript
|
||||
* import * as SpinePlugin from './SpinePlugin.js';
|
||||
* ```
|
||||
*
|
||||
* and then adding it to your Phaser Game configuration:
|
||||
*
|
||||
* ```javascript
|
||||
* plugins: {
|
||||
* scene: [
|
||||
* { key: 'SpinePlugin', plugin: window.SpinePlugin, mapping: 'spine' }
|
||||
* ]
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* If you're using ES5 then you can load the Spine Plugin in a Scene files payload, _within_ your
|
||||
* Game Configuration object, like this:
|
||||
*
|
||||
* ```javascript
|
||||
* scene: {
|
||||
* preload: preload,
|
||||
* create: create,
|
||||
* pack: {
|
||||
* files: [
|
||||
* { type: 'scenePlugin', key: 'SpinePlugin', url: 'plugins/SpinePlugin.js', sceneKey: 'spine' }
|
||||
* ]
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Loading it like this allows you to then use commands such as `this.load.spine` from within the
|
||||
* same Scene. Alternatively, you can use the method `this.load.plugin` to load the plugin via the normal
|
||||
* Phaser Loader. However, doing so will not add it to the current Scene. It will be available from any
|
||||
* subsequent Scenes.
|
||||
*
|
||||
* Assuming a default environment you access it from within a Scene by using the `this.spine` reference.
|
||||
*
|
||||
* When this plugin is installed into a Scene it will add a Loader File Type, allowing you to load
|
||||
|
|
|
@ -22,7 +22,61 @@ var SpineGameObjectRender = require('./SpineGameObjectRender');
|
|||
|
||||
/**
|
||||
* @classdesc
|
||||
* TODO
|
||||
* A Spine Game Object is a Phaser level object that can be added to your Phaser Scenes. It encapsulates
|
||||
* a Spine Skeleton with Spine Animation Data and Animation State, with helper methods to allow you to
|
||||
* easily change the skin, slot attachment, bone positions and more.
|
||||
*
|
||||
* Spine Game Objects can be created via the Game Object Factory, Game Object Creator, or directly.
|
||||
* You can only create them if the Spine plugin has been loaded into Phaser.
|
||||
*
|
||||
* The quickest way is the Game Object Factory:
|
||||
*
|
||||
* ```javascript
|
||||
* let jelly = this.add.spine(512, 550, 'jelly', 'jelly-think', true);
|
||||
* ```
|
||||
*
|
||||
* Here we are creating a new Spine Game Object positioned at 512 x 550. It's using the `jelly`
|
||||
* Spine data, which has previously been loaded into your Scene. The `jelly-think` argument is
|
||||
* an optional animation to start playing on the skeleton. The final argument `true` sets the
|
||||
* animation to loop. Look at the documentation for further details on each of these options.
|
||||
*
|
||||
* For more control, you can use the Game Object Creator, passing in a Spine Game Object
|
||||
* Configuration object:
|
||||
*
|
||||
* ```javascript
|
||||
* let jelly = this.make.spine({
|
||||
* x: 512, y: 550, key: 'jelly',
|
||||
* scale: 1.5,
|
||||
* skinName: 'square_Green',
|
||||
* animationName: 'jelly-think', loop: true,
|
||||
* slotName: 'hat', attachmentName: 'images/La_14'
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Here, you've got the ability to specify extra details, such as the slot name, attachments or
|
||||
* overall scale.
|
||||
*
|
||||
* If you wish to instantiate a Spine Game Object directly you can do so, but in order for it to
|
||||
* update and render, it must be added to the display and update lists of your Scene:
|
||||
*
|
||||
* ```javascript
|
||||
* let jelly = new SpineGameObject(this, this.spine, 512, 550, 'jelly', 'jelly-think', true);
|
||||
* this.sys.displayList.add(jelly);
|
||||
* this.sys.updateList.add(jelly);
|
||||
* ```
|
||||
*
|
||||
* It's possible to enable Spine Game Objects for input, but you should be aware that it will use
|
||||
* the bounds of the skeletons current pose to create the hit area from. Sometimes this is ok, but
|
||||
* often not. Make use of the `InputPlugin.enableDebug` method to view the input shape being created.
|
||||
* If it's not suitable, provide your own shape to the `setInteractive` method.
|
||||
*
|
||||
* Due to the way Spine handles scaling, it's not recommended to enable a Spine Game Object for
|
||||
* physics directly. Instead, you should look at creating a proxy body and syncing the Spine Game
|
||||
* Object position with it. See the examples for further details.
|
||||
*
|
||||
* If your Spine Game Object has black outlines around the different parts of the texture when it
|
||||
* renders then you have exported the files from Spine with pre-multiplied alpha enabled, but have
|
||||
* forgotten to set that flag when loading the Spine data. Please see the loader docs for more details.
|
||||
*
|
||||
* @class SpineGameObject
|
||||
* @constructor
|
||||
|
|
Loading…
Add table
Reference in a new issue