phaser/v3/src/components/Animation.js

99 lines
2.7 KiB
JavaScript
Raw Normal View History

2017-04-04 22:59:16 +00:00
var Class = require('../utils/Class');
var Components = require('../animation/frame/');
2017-04-04 22:59:16 +00:00
var Animation = new Class({
initialize:
2017-04-04 22:59:16 +00:00
function Animation (parent)
2017-04-05 01:06:28 +00:00
{
// Sprite / Game Object
this.parent = parent;
2017-04-05 01:06:28 +00:00
this.animationManager = parent.state.sys.anims;
this.mainloop = parent.state.game.mainloop;
2017-04-05 01:06:28 +00:00
this.isPlaying = false;
// Reference to the Phaser.Animation object
this.currentAnim = null;
// Reference to the Phaser.AnimationFrame object
this.currentFrame = null;
// Animation specific values
// -------------------------
2017-04-05 01:06:28 +00:00
// Scale the time (make it go faster / slower)
2017-04-06 23:34:06 +00:00
// Factor that's used to scale time where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc.
this._timeScale = 1;
2017-04-04 22:59:16 +00:00
// The frame rate of playback in frames per second (default 24 if duration is null)
this.frameRate = 0;
2017-04-05 00:15:53 +00:00
// How long the animation should play for. If framerate is set it overrides this value
// otherwise framerate is derived from duration
this.duration = 0;
2017-04-04 22:59:16 +00:00
// ms per frame (without including frame specific modifiers)
this.msPerFrame = 0;
// Skip frames if the time lags, or always advanced anyway?
this.skipMissedFrames = true;
// Delay before starting playback (in seconds)
this._delay = 0;
// Number of times to repeat the animation (-1 for infinity)
this._repeat = 0;
2017-04-04 22:59:16 +00:00
// Delay before the repeat starts (in seconds)
this._repeatDelay = 0;
2017-04-04 22:59:16 +00:00
// Should the animation yoyo? (reverse back down to the start) before repeating?
this._yoyo = false;
2017-04-05 00:15:53 +00:00
// Playhead values
// ---------------
2017-04-04 22:59:16 +00:00
// Move the playhead forward (true) or in reverse (false)
2017-04-05 01:06:28 +00:00
this.forward = true;
this.accumulator = 0;
this.prevTick = 0;
this.nextTick = 0;
this.repeatCounter = 0;
this.pendingRepeat = false;
this._paused = false;
this._wasPlaying = false;
},
delay: Components.Delay,
delayedPlay: Components.DelayedPlay,
load: Components.Load,
pause: Components.Pause,
paused: Components.Paused,
play: Components.Play,
progress: Components.Progress,
repeat: Components.Repeat,
repeatDelay: Components.RepeatDelay,
restart: Components.Restart,
resume: Components.Resume,
stop: Components.Stop,
2017-04-06 23:34:06 +00:00
timeScale: Components.TimeScale,
totalFrames: Components.TotalFrames,
totalProgress: Components.TotalProgress,
update: Components.Update,
updateFrame: Components.UpdateFrame,
yoyo: Components.Yoyo
2017-04-05 14:27:26 +00:00
});
2017-04-04 22:59:16 +00:00
module.exports = Animation;