2013-04-12 16:19:56 +00:00
|
|
|
/// <reference path="../../Game.ts" />
|
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
/**
|
2013-04-18 15:49:08 +00:00
|
|
|
* Phaser - Frame
|
|
|
|
*
|
|
|
|
* A Frame is a single frame of an animation and is part of a FrameData collection.
|
2013-04-18 13:16:18 +00:00
|
|
|
*/
|
2013-04-12 16:19:56 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
module Phaser {
|
2013-04-12 16:19:56 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
export class Frame {
|
2013-04-12 16:19:56 +00:00
|
|
|
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* Frame constructor
|
|
|
|
* Create a new <code>Frame</code> with specific position, size and name.
|
|
|
|
*
|
|
|
|
* @param x X position within the image to cut from.
|
|
|
|
* @param y Y position within the image to cut from.
|
|
|
|
* @param width Width of the frame.
|
|
|
|
* @param height Height of the frame.
|
|
|
|
* @param name Name of this frame.
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
constructor(x: number, y: number, width: number, height: number, name: string) {
|
2013-04-12 16:19:56 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
|
|
|
this.width = width;
|
|
|
|
this.height = height;
|
|
|
|
this.name = name;
|
2013-04-12 16:19:56 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
this.rotated = false;
|
|
|
|
this.trimmed = false;
|
2013-04-12 16:19:56 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
}
|
2013-04-15 14:42:13 +00:00
|
|
|
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* X position within the image to cut from.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public x: number;
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* Y position within the image to cut from.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public y: number;
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* Width of the frame.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public width: number;
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* Height of the frame.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public height: number;
|
2013-04-12 16:19:56 +00:00
|
|
|
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* Useful for Sprite Sheets.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public index: number;
|
2013-04-12 16:19:56 +00:00
|
|
|
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* Useful for Texture Atlas files. (is set to the filename value)
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public name: string = '';
|
2013-04-12 16:19:56 +00:00
|
|
|
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* Rotated? (not yet implemented)
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public rotated: bool = false;
|
2013-04-12 16:19:56 +00:00
|
|
|
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* Either cw or ccw, rotation is always 90 degrees.
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public rotationDirection: string = 'cw';
|
2013-04-12 16:19:56 +00:00
|
|
|
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* Was it trimmed when packed?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public trimmed: bool;
|
|
|
|
|
|
|
|
// The coordinates of the trimmed sprite inside the original sprite
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* Width of the original sprite.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public sourceSizeW: number;
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* Height of the original sprite.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public sourceSizeH: number;
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* X position of the trimmed sprite inside original sprite.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public spriteSourceSizeX: number;
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* Y position of the trimmed sprite inside original sprite.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public spriteSourceSizeY: number;
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* Width of the trimmed sprite.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public spriteSourceSizeW: number;
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* Height of the trimmed sprite.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public spriteSourceSizeH: number;
|
|
|
|
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* Set rotation of this frame. (Not yet supported!)
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public setRotation(rotated: bool, rotationDirection: string) {
|
|
|
|
// Not yet supported
|
|
|
|
}
|
|
|
|
|
2013-05-03 11:32:39 +00:00
|
|
|
/**
|
|
|
|
* Set trim of the frame.
|
|
|
|
* @param trimmed Whether this frame trimmed or not.
|
|
|
|
* @param actualWidth Actual width of this frame.
|
|
|
|
* @param actualHeight Actual height of this frame.
|
|
|
|
* @param destX Destiny x position.
|
|
|
|
* @param destY Destiny y position.
|
|
|
|
* @param destWidth Destiny draw width.
|
|
|
|
* @param destHeight Destiny draw height.
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public setTrim(trimmed: bool, actualWidth, actualHeight, destX, destY, destWidth, destHeight, ) {
|
2013-04-12 16:19:56 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
this.trimmed = trimmed;
|
2013-04-12 16:19:56 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
this.sourceSizeW = actualWidth;
|
|
|
|
this.sourceSizeH = actualHeight;
|
|
|
|
this.spriteSourceSizeX = destX;
|
|
|
|
this.spriteSourceSizeY = destY;
|
|
|
|
this.spriteSourceSizeW = destWidth;
|
|
|
|
this.spriteSourceSizeH = destHeight;
|
2013-04-12 16:19:56 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
}
|
2013-04-12 16:19:56 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
}
|