mirror of
https://github.com/wassname/phaser.git
synced 2026-07-20 12:30:48 +08:00
1.0.3 release - fixed Text and Bitmap Fonts, Animation documentation and more examples
This commit is contained in:
+137
-77
@@ -1,123 +1,181 @@
|
||||
/**
|
||||
* Frame
|
||||
*
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @module Phaser.Animation
|
||||
*/
|
||||
|
||||
/**
|
||||
* A Frame is a single frame of an animation and is part of a FrameData collection.
|
||||
*
|
||||
* @package Phaser.Animation.Frame
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @class Frame
|
||||
* @constructor
|
||||
* @param {Number} index The index of this Frame within the FrameData set it is being added to.
|
||||
* @param {Number} x X position of the frame within the texture image.
|
||||
* @param {Number} y Y position of the frame within the texture image.
|
||||
* @param {Number} width Width of the frame within the texture image.
|
||||
* @param {Number} height Height of the frame within the texture image.
|
||||
* @param {String} name The name of the frame. In Texture Atlas data this is usually set to the filename.
|
||||
* @param {String} uuid Internal UUID key.
|
||||
*/
|
||||
Phaser.Animation.Frame = function (x, y, width, height, name, uuid) {
|
||||
Phaser.Animation.Frame = function (index, x, y, width, height, name, uuid) {
|
||||
|
||||
/**
|
||||
* X position within the image to cut from.
|
||||
* @type {number}
|
||||
*/
|
||||
* The index of this Frame within the FrameData set it is being added to.
|
||||
* @property index
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.index = index;
|
||||
|
||||
/**
|
||||
* X position within the image to cut from.
|
||||
* @property x
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.x = x;
|
||||
|
||||
/**
|
||||
* Y position within the image to cut from.
|
||||
* @type {number}
|
||||
*/
|
||||
* Y position within the image to cut from.
|
||||
* @property y
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.y = y;
|
||||
|
||||
/**
|
||||
* Width of the frame.
|
||||
* @type {number}
|
||||
*/
|
||||
* Width of the frame.
|
||||
* @property width
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.width = width;
|
||||
|
||||
/**
|
||||
* Height of the frame.
|
||||
* @type {number}
|
||||
*/
|
||||
* Height of the frame.
|
||||
* @property height
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.height = height;
|
||||
|
||||
/**
|
||||
* center X position within the image to cut from.
|
||||
* @type {number}
|
||||
*/
|
||||
this.centerX = Math.floor(width / 2);
|
||||
|
||||
/**
|
||||
* center Y position within the image to cut from.
|
||||
* @type {number}
|
||||
*/
|
||||
this.centerY = Math.floor(height / 2);
|
||||
|
||||
/**
|
||||
* Useful for Sprite Sheets.
|
||||
* @type {number}
|
||||
*/
|
||||
this.index = 0;
|
||||
|
||||
/**
|
||||
* Useful for Texture Atlas files. (is set to the filename value)
|
||||
*/
|
||||
* Useful for Texture Atlas files. (is set to the filename value)
|
||||
* @property name
|
||||
* @public
|
||||
* @type {String}
|
||||
*/
|
||||
this.name = name;
|
||||
|
||||
/**
|
||||
* A link to the PIXI.TextureCache entry
|
||||
*/
|
||||
* A link to the PIXI.TextureCache entry
|
||||
* @property uuid
|
||||
* @public
|
||||
* @type {String}
|
||||
*/
|
||||
this.uuid = uuid;
|
||||
|
||||
/**
|
||||
* The distance from the top left to the bottom-right of this Frame.
|
||||
* @type {number}
|
||||
*/
|
||||
* center X position within the image to cut from.
|
||||
* @property centerX
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.centerX = Math.floor(width / 2);
|
||||
|
||||
/**
|
||||
* center Y position within the image to cut from.
|
||||
* @property centerY
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.centerY = Math.floor(height / 2);
|
||||
|
||||
/**
|
||||
* The distance from the top left to the bottom-right of this Frame.
|
||||
* @property distance
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.distance = Phaser.Math.distance(0, 0, width, height);
|
||||
|
||||
/**
|
||||
* Rotated? (not yet implemented)
|
||||
*/
|
||||
* Rotated? (not yet implemented)
|
||||
* @property rotated
|
||||
* @public
|
||||
* @type {Boolean}
|
||||
* @default false
|
||||
*/
|
||||
this.rotated = false;
|
||||
|
||||
/**
|
||||
* Either cw or ccw, rotation is always 90 degrees.
|
||||
*/
|
||||
* Either cw or ccw, rotation is always 90 degrees.
|
||||
* @property rotationDirection
|
||||
* @public
|
||||
* @type {String}
|
||||
* @default "cw"
|
||||
*/
|
||||
this.rotationDirection = 'cw';
|
||||
|
||||
/**
|
||||
* Was it trimmed when packed?
|
||||
* @type {bool}
|
||||
*/
|
||||
* Was it trimmed when packed?
|
||||
* @property trimmed
|
||||
* @public
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.trimmed = false;
|
||||
|
||||
/**
|
||||
* Width of the original sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
* Width of the original sprite.
|
||||
* @property sourceSizeW
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.sourceSizeW = width;
|
||||
|
||||
/**
|
||||
* Height of the original sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
* Height of the original sprite.
|
||||
* @property sourceSizeH
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.sourceSizeH = height;
|
||||
|
||||
/**
|
||||
* X position of the trimmed sprite inside original sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
* X position of the trimmed sprite inside original sprite.
|
||||
* @property spriteSourceSizeX
|
||||
* @public
|
||||
* @type {Number}
|
||||
* @default 0
|
||||
*/
|
||||
this.spriteSourceSizeX = 0;
|
||||
|
||||
/**
|
||||
* Y position of the trimmed sprite inside original sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
* Y position of the trimmed sprite inside original sprite.
|
||||
* @property spriteSourceSizeY
|
||||
* @public
|
||||
* @type {Number}
|
||||
* @default 0
|
||||
*/
|
||||
this.spriteSourceSizeY = 0;
|
||||
|
||||
/**
|
||||
* Width of the trimmed sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
* Width of the trimmed sprite.
|
||||
* @property spriteSourceSizeW
|
||||
* @public
|
||||
* @type {Number}
|
||||
* @default 0
|
||||
*/
|
||||
this.spriteSourceSizeW = 0;
|
||||
|
||||
/**
|
||||
* Height of the trimmed sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
* Height of the trimmed sprite.
|
||||
* @property spriteSourceSizeH
|
||||
* @public
|
||||
* @type {Number}
|
||||
* @default 0
|
||||
*/
|
||||
this.spriteSourceSizeH = 0;
|
||||
|
||||
};
|
||||
@@ -125,14 +183,16 @@ Phaser.Animation.Frame = function (x, y, width, height, name, uuid) {
|
||||
Phaser.Animation.Frame.prototype = {
|
||||
|
||||
/**
|
||||
* Set trim of the frame.
|
||||
* @param trimmed {bool} Whether this frame trimmed or not.
|
||||
* @param actualWidth {number} Actual width of this frame.
|
||||
* @param actualHeight {number} Actual height of this frame.
|
||||
* @param destX {number} Destination x position.
|
||||
* @param destY {number} Destination y position.
|
||||
* @param destWidth {number} Destination draw width.
|
||||
* @param destHeight {number} Destination draw height.
|
||||
* If the frame was trimmed when added to the Texture Atlas this records the trim and source data.
|
||||
*
|
||||
* @method setTrim
|
||||
* @param {Boolean} trimmed If this frame was trimmed or not.
|
||||
* @param {Number} actualWidth The width of the frame before being trimmed.
|
||||
* @param {Number} actualHeight The height of the frame before being trimmed.
|
||||
* @param {Number} destX The destination X position of the trimmed frame for display.
|
||||
* @param {Number} destY The destination Y position of the trimmed frame for display.
|
||||
* @param {Number} destWidth The destination width of the trimmed frame for display.
|
||||
* @param {Number} destHeight The destination height of the trimmed frame for display.
|
||||
*/
|
||||
setTrim: function (trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user