phaser/Phaser/system/animation/Frame.ts

74 lines
1.9 KiB
TypeScript
Raw Normal View History

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-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-18 13:16:18 +00:00
// Position within the image to cut from
public x: number;
public y: number;
public width: number;
public height: number;
2013-04-12 16:19:56 +00:00
2013-04-18 13:16:18 +00:00
// Useful for Sprite Sheets
public index: number;
2013-04-12 16:19:56 +00:00
2013-04-18 13:16:18 +00:00
// Useful for Texture Atlas files (is set to the filename value)
public name: string = '';
2013-04-12 16:19:56 +00:00
2013-04-18 13:16:18 +00:00
// Rotated? (not yet implemented)
public rotated: bool = false;
2013-04-12 16:19:56 +00:00
2013-04-18 13:16:18 +00:00
// Either cw or ccw, rotation is always 90 degrees
public rotationDirection: string = 'cw';
2013-04-12 16:19:56 +00:00
2013-04-18 13:16:18 +00:00
// Was it trimmed when packed?
public trimmed: bool;
// The coordinates of the trimmed sprite inside the original sprite
public sourceSizeW: number;
public sourceSizeH: number;
public spriteSourceSizeX: number;
public spriteSourceSizeY: number;
public spriteSourceSizeW: number;
public spriteSourceSizeH: number;
public setRotation(rotated: bool, rotationDirection: string) {
// Not yet supported
}
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
}