Navigation
These archived docs are for Phaser 2.3.0 Phaser 3 docs can be found on newdocs.phaser.io.
Phaser CE docs can be found on the Phaser CE Documentation site.

Constructor

Phaser. Frame

new Frame(index, x, y, width, height, name, uuid)

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.

uuid string

Internal UUID key.

Source code: animation/Frame.js (Line 20)

Public Properties

bottom : number

The bottom of the frame (y + height).

Source code: animation/Frame.js (Line 132)

centerX : number

Center X position within the image to cut from.

Source code: animation/Frame.js (Line 60)

centerY : number

Center Y position within the image to cut from.

Source code: animation/Frame.js (Line 65)

distance : number

The distance from the top left to the bottom-right of this Frame.

Source code: animation/Frame.js (Line 70)

height : number

Height of the frame.

Source code: animation/Frame.js (Line 45)

index : number

The index of this Frame within the FrameData set it is being added to.

Source code: animation/Frame.js (Line 25)

name : string

Useful for Texture Atlas files (is set to the filename value).

Source code: animation/Frame.js (Line 50)

The right of the Frame (x + width).

Source code: animation/Frame.js (Line 127)

rotated : boolean

Rotated? (not yet implemented)

Default Value
  • false
Source code: animation/Frame.js (Line 76)

rotationDirection : string

Either 'cw' or 'ccw', rotation is always 90 degrees.

Default Value
  • 'cw'
Source code: animation/Frame.js (Line 82)

sourceSizeH : number

Height of the original sprite.

Source code: animation/Frame.js (Line 98)

sourceSizeW : number

Width of the original sprite.

Source code: animation/Frame.js (Line 93)

spriteSourceSizeH : number

Height of the trimmed sprite.

Default Value
  • 0
Source code: animation/Frame.js (Line 122)

spriteSourceSizeW : number

Width of the trimmed sprite.

Default Value
  • 0
Source code: animation/Frame.js (Line 116)

spriteSourceSizeX : number

X position of the trimmed sprite inside original sprite.

Default Value
  • 0
Source code: animation/Frame.js (Line 104)

spriteSourceSizeY : number

Y position of the trimmed sprite inside original sprite.

Default Value
  • 0
Source code: animation/Frame.js (Line 110)

trimmed : boolean

Was it trimmed when packed?

Default Value
  • false
Source code: animation/Frame.js (Line 88)

uuid : string

DEPRECATED: A link to the PIXI.TextureCache entry.

Source code: animation/Frame.js (Line 55)

width : number

Width of the frame.

Source code: animation/Frame.js (Line 40)

x : number

X position within the image to cut from.

Source code: animation/Frame.js (Line 30)

y : number

Y position within the image to cut from.

Source code: animation/Frame.js (Line 35)

Public Methods

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.

Source code: animation/Frame.js (Line 168)

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.

Source code: animation/Frame.js (Line 191)

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.

Source code: animation/Frame.js (Line 138)