phaser/Phaser/system/animation/FrameData.js
Richard Davey e74114f384 Docs
2013-08-12 00:52:35 +01:00

84 lines
2.8 KiB
JavaScript

/// <reference path="../../Game.ts" />
/**
* Phaser - FrameData
*
* FrameData is a container for Frame objects, the internal representation of animation data in Phaser.
*/
var Phaser;
(function (Phaser) {
var FrameData = (function () {
function FrameData() {
this._frames = [];
this._frameNames = [];
}
Object.defineProperty(FrameData.prototype, "total", {
get: function () {
return this._frames.length;
},
enumerable: true,
configurable: true
});
FrameData.prototype.addFrame = function (frame) {
frame.index = this._frames.length;
this._frames.push(frame);
if(frame.name !== '') {
this._frameNames[frame.name] = frame.index;
}
return frame;
};
FrameData.prototype.getFrame = function (index) {
if(this._frames[index]) {
return this._frames[index];
}
return null;
};
FrameData.prototype.getFrameByName = function (name) {
if(this._frameNames[name] >= 0) {
return this._frames[this._frameNames[name]];
}
return null;
};
FrameData.prototype.checkFrameName = function (name) {
if(this._frameNames[name] >= 0) {
return true;
}
return false;
};
FrameData.prototype.getFrameRange = function (start, end, output) {
if (typeof output === "undefined") { output = []; }
for(var i = start; i <= end; i++) {
output.push(this._frames[i]);
}
return output;
};
FrameData.prototype.getFrameIndexes = function (output) {
if (typeof output === "undefined") { output = []; }
output.length = 0;
for(var i = 0; i < this._frames.length; i++) {
output.push(i);
}
return output;
};
FrameData.prototype.getFrameIndexesByName = function (input) {
var output = [];
for(var i = 0; i < input.length; i++) {
if(this.getFrameByName(input[i])) {
output.push(this.getFrameByName(input[i]).index);
}
}
return output;
};
FrameData.prototype.getAllFrames = function () {
return this._frames;
};
FrameData.prototype.getFrames = function (range) {
var output = [];
for(var i = 0; i < range.length; i++) {
output.push(this._frames[i]);
}
return output;
};
return FrameData;
})();
Phaser.FrameData = FrameData;
})(Phaser || (Phaser = {}));