Merge remote-tracking branch 'origin/master'

This commit is contained in:
Pavle Goloskokovic 2018-01-21 15:16:18 +01:00
commit b82179268f
2 changed files with 266 additions and 0 deletions

View file

@ -15,16 +15,52 @@ var Animation = new Class({
initialize:
/**
* [description]
*
* @class Animation
* @memberOf Phaser.Animations
* @constructor
* @since 3.0.0
*
* @param {undefined} manager - [description]
* @param {undefined} key - [description]
* @param {undefined} config - [description]
*/
function Animation (manager, key, config)
{
/**
* [description]
*
* @property {Phaser.Animations.AnimationManager} manager
* @since 3.0.0
*/
this.manager = manager;
/**
* [description]
*
* @property {string} key
*/
this.key = key;
// A frame based animation (as opposed to a bone based animation)
/**
* [description]
*
* @property {string} type
* @default frame
*/
this.type = 'frame';
// Extract all the frame data into the frames array
/**
* [description]
*
* @property {array} frames
*/
this.frames = this.getFrames(
manager.textureManager,
GetValue(config, 'frames', []),
@ -32,10 +68,25 @@ var Animation = new Class({
);
// The frame rate of playback in frames per second (default 24 if duration is null)
/**
* [description]
*
* @property {integer} frameRate
* @default 24
* @since 3.0.0
*/
this.frameRate = GetValue(config, 'frameRate', null);
// How long the animation should play for. If frameRate is set it overrides this value
// otherwise frameRate is derived from duration
/**
* [description]
*
* @property {integer} duration
* @since 3.0.0
*/
this.duration = GetValue(config, 'duration', null);
if (this.duration === null && this.frameRate === null)
@ -60,49 +111,171 @@ var Animation = new Class({
}
// ms per frame (without including frame specific modifiers)
/**
* [description]
*
* @property {integer} msPerFrame
*/
this.msPerFrame = 1000 / this.frameRate;
// Skip frames if the time lags, or always advanced anyway?
/**
* [description]
*
* @property {boolean} skipMissedFrames
* @default false
*/
this.skipMissedFrames = GetValue(config, 'skipMissedFrames', true);
// Delay before starting playback (in seconds)
/**
* [description]
*
* @property {integer} delay
* @default 0
*/
this.delay = GetValue(config, 'delay', 0);
// Number of times to repeat the animation (-1 for infinity)
/**
* [description]
*
* @property {integer} repeat
* @default 0
*/
this.repeat = GetValue(config, 'repeat', 0);
// Delay before the repeat starts (in seconds)
/**
* [description]
*
* @property {integer} repeatDelay
* @default 0
*/
this.repeatDelay = GetValue(config, 'repeatDelay', 0);
// Should the animation yoyo? (reverse back down to the start) before repeating?
/**
* [description]
*
* @property {boolean} yoyo
* @default false
*/
this.yoyo = GetValue(config, 'yoyo', false);
// Should sprite.visible = true when the animation starts to play?
/**
* [description]
*
* @property {boolean} showOnStart
* @default false
*/
this.showOnStart = GetValue(config, 'showOnStart', false);
// Should sprite.visible = false when the animation finishes?
/**
* [description]
*
* @property {boolean} hideOnComplete
* @default false
*/
this.hideOnComplete = GetValue(config, 'hideOnComplete', false);
// Callbacks
/**
* [description]
*
* @property {object} callbackScope
*/
this.callbackScope = GetValue(config, 'callbackScope', this);
/**
* [description]
*
* @property {function} onStart
*/
this.onStart = GetValue(config, 'onStart', false);
/**
* [description]
*
* @property {array} onStartParams
*/
this.onStartParams = GetValue(config, 'onStartParams', []);
/**
* [description]
*
* @property {function} onRepeat
*/
this.onRepeat = GetValue(config, 'onRepeat', false);
/**
* [description]
*
* @property {array} onRepeatParams
*/
this.onRepeatParams = GetValue(config, 'onRepeatParams', []);
// Called for EVERY frame of the animation.
// See AnimationFrame.onUpdate for a frame specific callback.
/**
* [description]
*
* @property {function} onUpdate
*/
this.onUpdate = GetValue(config, 'onUpdate', false);
/**
* [description]
*
* @property {array} onUpdateParams
*/
this.onUpdateParams = GetValue(config, 'onUpdateParams', []);
/**
* [description]
*
* @property {function} onComplete
*/
this.onComplete = GetValue(config, 'onComplete', false);
/**
* [description]
*
* @property {array} onCompleteParams
*/
this.onCompleteParams = GetValue(config, 'onCompleteParams', []);
// Global pause, effects all Game Objects using this Animation instance
/**
* [description]
*
* @property {boolean} paused
* @default false
*/
this.paused = false;
/**
* [description]
*
* @property {null} manager.on('pauseall', this.pause.bind(this))
*/
this.manager.on('pauseall', this.pause.bind(this));
this.manager.on('resumeall', this.resume.bind(this));
},

View file

@ -6,43 +6,136 @@ var AnimationFrame = new Class({
initialize:
/**
* [description]
*
* @class AnimationFrame
* @memberOf Phaser.Animations.AnimationFrame
* @constructor
* @since 3.0.0
*
* @param {undefined} textureKey - [description]
* @param {undefined} textureFrame - [description]
* @param {undefined} index - [description]
* @param {undefined} frame - [description]
*/
function AnimationFrame (textureKey, textureFrame, index, frame)
{
// The keys into the Texture Manager of the texture + frame this uses
/**
* [description]
*
* @property {string} textureKey
*/
this.textureKey = textureKey;
/**
* [description]
*
* @property {Phaser.Textures.Frame} textureFrame
*/
this.textureFrame = textureFrame;
// The index of this frame within the Animation.frames array
/**
* [description]
*
* @property {integer} index
*/
this.index = index;
// Texture Frame
/**
* [description]
*
* @property {Phaser.Textures.Frame} frame
*/
this.frame = frame;
// Read-only
/**
* [description]
*
* @property {boolean} isFirst
* @default false
*/
this.isFirst = false;
// Read-only
/**
* [description]
*
* @property {boolean} isLast
* @default false
*/
this.isLast = false;
// The frame that comes before this one in the animation (if any)
// Read-only
/**
* [description]
*
* @property {?[type]} prevFrame
* @default null
*/
this.prevFrame = null;
// The frame that comes after this one in the animation (if any)
// Read-only
/**
* [description]
*
* @property {?[type]} nextFrame
* @default null
*/
this.nextFrame = null;
// Additional time (in ms) this frame should appear for - added onto the msPerFrame
/**
* [description]
*
* @property {number} duration
* @default 0
*/
this.duration = 0;
// What % through the animation progress is this frame?
// Read-only
/**
* [description]
*
* @property {number} progress
* @default 0
*/
this.progress = 0;
// Callback if this frame gets displayed
/**
* [description]
*
* @property {?[type]} onUpdate
* @default null
*/
this.onUpdate = null;
// When this frame hits, set sprite.visible to this
/**
* [description]
*
* @property {boolean} setVisible
* @default false
*/
this.setVisible = false;
this.visible = false;