On this page
Class: Phaser.Frame
Constructor
new Frame(index, x, y, width, height, name)
A Frame is a single frame of an animation and is part of a FrameData collection.
Parameters
Name | Type | Description |
---|---|---|
index |
number | The index of this Frame within the FrameData set it is being added to. |
x |
number | X position of the frame within the texture image. |
y |
number | Y position of the frame within the texture image. |
width |
number | Width of the frame within the texture image. |
height |
number | Height of the frame within the texture image. |
name |
string | The name of the frame. In Texture Atlas data this is usually set to the filename. |
- Source code: animation/Frame.js (Line 19)
Public Properties
- Source code: animation/Frame.js (Line 126)
- Source code: animation/Frame.js (Line 54)
- Source code: animation/Frame.js (Line 59)
- Source code: animation/Frame.js (Line 64)
- Source code: animation/Frame.js (Line 44)
- Source code: animation/Frame.js (Line 24)
- Source code: animation/Frame.js (Line 49)
- Source code: animation/Frame.js (Line 121)
- Source code: animation/Frame.js (Line 70)
- Default Value
-
- 'cw'
- Source code: animation/Frame.js (Line 76)
- Source code: animation/Frame.js (Line 92)
- Source code: animation/Frame.js (Line 87)
- Source code: animation/Frame.js (Line 116)
- Source code: animation/Frame.js (Line 110)
- Source code: animation/Frame.js (Line 98)
- Source code: animation/Frame.js (Line 104)
- Source code: animation/Frame.js (Line 82)
- Source code: animation/Frame.js (Line 39)
- Source code: animation/Frame.js (Line 29)
- Source code: animation/Frame.js (Line 34)
bottom : number
The bottom of the frame (y + height).
centerX : number
Center X position within the image to cut from.
centerY : number
Center Y position within the image to cut from.
distance : number
The distance from the top left to the bottom-right of this Frame.
height : number
Height of the frame.
index : number
The index of this Frame within the FrameData set it is being added to.
name : string
Useful for Texture Atlas files (is set to the filename value).
right : number
The right of the Frame (x + width).
rotated : boolean
Rotated? (not yet implemented)
rotationDirection : string
Either 'cw' or 'ccw', rotation is always 90 degrees.
sourceSizeH : number
Height of the original sprite before it was trimmed.
sourceSizeW : number
Width of the original sprite before it was trimmed.
spriteSourceSizeH : number
Height of the trimmed sprite.
spriteSourceSizeW : number
Width of the trimmed sprite.
spriteSourceSizeX : number
X position of the trimmed sprite inside original sprite.
spriteSourceSizeY : number
Y position of the trimmed sprite inside original sprite.
trimmed : boolean
Was it trimmed when packed?
width : number
Width of the frame.
x : number
X position within the image to cut from.
y : number
Y position within the image to cut from.
Public Methods
- Source code: animation/Frame.js (Line 183)
- Source code: animation/Frame.js (Line 206)
- Source code: animation/Frame.js (Line 132)
- Source code: animation/Frame.js (Line 153)
clone() → {Phaser.Frame}
Clones this Frame into a new Phaser.Frame object and returns it.
Note that all properties are cloned, including the name, index and UUID.
Returns
An exact copy of this Frame object.
getRect(out) → {Phaser.Rectangle}
Returns a Rectangle set to the dimensions of this Frame.
Parameters
Name | Type | Argument | Description |
---|---|---|---|
out |
Phaser.Rectangle | <optional> |
A rectangle to copy the frame dimensions to. |
Returns
A rectangle.
resize(width, height)
Adjusts of all the Frame properties based on the given width and height values.
Parameters
Name | Type | Description |
---|---|---|
width |
integer | The new width of the Frame. |
height |
integer | The new height of the Frame. |
setTrim(trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight)
If the frame was trimmed when added to the Texture Atlas this records the trim and source data.
Parameters
Name | Type | Description |
---|---|---|
trimmed |
boolean | If this frame was trimmed or not. |
actualWidth |
number | The width of the frame before being trimmed. |
actualHeight |
number | The height of the frame before being trimmed. |
destX |
number | The destination X position of the trimmed frame for display. |
destY |
number | The destination Y position of the trimmed frame for display. |
destWidth |
number | The destination width of the trimmed frame for display. |
destHeight |
number | The destination height of the trimmed frame for display. |
© 2016 Richard Davey, Photon Storm Ltd.
Licensed under the MIT License.
http://phaser.io/docs/2.6.2/Phaser.Frame.html