Expose manager functions. Fix #5345

This commit is contained in:
Richard Davey 2020-10-06 09:59:02 +01:00
parent 00b8bb4e0f
commit b285b2b5bb

View file

@ -1701,6 +1701,99 @@ var AnimationState = new Class({
return anim;
},
/**
* Generate an array of {@link Phaser.Types.Animations.AnimationFrame} objects from a texture key and configuration object.
*
* Generates objects with string based frame names, as configured by the given {@link Phaser.Types.Animations.GenerateFrameNames}.
*
* It's a helper method, designed to make it easier for you to extract all of the frame names from texture atlases.
* If you're working with a sprite sheet, see the `generateFrameNumbers` method instead.
*
* Example:
*
* If you have a texture atlases loaded called `gems` and it contains 6 frames called `ruby_0001`, `ruby_0002`, and so on,
* then you can call this method using: `this.anims.generateFrameNames('gems', { prefix: 'ruby_', end: 6, zeroPad: 4 })`.
*
* The `end` value tells it to look for 6 frames, incrementally numbered, all starting with the prefix `ruby_`. The `zeroPad`
* value tells it how many zeroes pad out the numbers. To create an animation using this method, you can do:
*
* ```javascript
* this.anims.create({
* key: 'ruby',
* repeat: -1,
* frames: this.anims.generateFrameNames('gems', {
* prefix: 'ruby_',
* end: 6,
* zeroPad: 4
* })
* });
* ```
*
* Please see the animation examples for further details.
*
* @method Phaser.Animations.AnimationState#generateFrameNames
* @since 3.50.0
*
* @param {string} key - The key for the texture containing the animation frames.
* @param {Phaser.Types.Animations.GenerateFrameNames} [config] - The configuration object for the animation frame names.
*
* @return {Phaser.Types.Animations.AnimationFrame[]} The array of {@link Phaser.Types.Animations.AnimationFrame} objects.
*/
generateFrameNames: function (key, config)
{
return this.animationManager.generateFrameNames(key, config);
},
/**
* Generate an array of {@link Phaser.Types.Animations.AnimationFrame} objects from a texture key and configuration object.
*
* Generates objects with numbered frame names, as configured by the given {@link Phaser.Types.Animations.GenerateFrameNumbers}.
*
* If you're working with a texture atlas, see the `generateFrameNames` method instead.
*
* It's a helper method, designed to make it easier for you to extract frames from sprite sheets.
* If you're working with a texture atlas, see the `generateFrameNames` method instead.
*
* Example:
*
* If you have a sprite sheet loaded called `explosion` and it contains 12 frames, then you can call this method using:
* `this.anims.generateFrameNumbers('explosion', { start: 0, end: 12 })`.
*
* The `end` value tells it to stop after 12 frames. To create an animation using this method, you can do:
*
* ```javascript
* this.anims.create({
* key: 'boom',
* frames: this.anims.generateFrameNames('explosion', {
* start: 0,
* end: 12
* })
* });
* ```
*
* Note that `start` is optional and you don't need to include it if the animation starts from frame 0.
*
* To specify an animation in reverse, swap the `start` and `end` values.
*
* If the frames are not sequential, you may pass an array of frame numbers instead, for example:
*
* `this.anims.generateFrameNumbers('explosion', { frames: [ 0, 1, 2, 1, 2, 3, 4, 0, 1, 2 ] })`
*
* Please see the animation examples and `GenerateFrameNumbers` config docs for further details.
*
* @method Phaser.Animations.AnimationState#generateFrameNumbers
* @since 3.50.0
*
* @param {string} key - The key for the texture containing the animation frames.
* @param {Phaser.Types.Animations.GenerateFrameNumbers} config - The configuration object for the animation frames.
*
* @return {Phaser.Types.Animations.AnimationFrame[]} The array of {@link Phaser.Types.Animations.AnimationFrame} objects.
*/
generateFrameNumbers: function (key, config)
{
return this.animationManager.generateFrameNumbers(key, config);
},
/**
* Removes a locally created Animation from this Sprite, based on the given key.
*