Class: Frame

Phaser. Frame

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:
src/animation/Frame.js line 19

Members

bottom :number

The bottom of the frame (y + height).

Type:
  • number
Source:
src/animation/Frame.js line 125

centerX :number

Center X position within the image to cut from.

Type:
  • number
Source:
src/animation/Frame.js line 59

centerY :number

Center Y position within the image to cut from.

Type:
  • number
Source:
src/animation/Frame.js line 64

distance :number

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

Type:
  • number
Source:
src/animation/Frame.js line 69

height :number

Height of the frame.

Type:
  • number
Source:
src/animation/Frame.js line 44

index :number

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

Type:
  • number
Source:
src/animation/Frame.js line 24

name :string

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

Type:
  • string
Source:
src/animation/Frame.js line 54

The right of the Frame (x + width).

Type:
  • number
Source:
src/animation/Frame.js line 120

rotated :boolean

Is the frame rotated in the source texture?

Type:
  • boolean
Source:
src/animation/Frame.js line 75

sourceSizeH :number

Height of the original sprite before it was trimmed.

Type:
  • number
Source:
src/animation/Frame.js line 91

sourceSizeW :number

Width of the original sprite before it was trimmed.

Type:
  • number
Source:
src/animation/Frame.js line 86

spriteSourceSizeH :number

Height of the trimmed sprite.

Type:
  • number
Source:
src/animation/Frame.js line 115

spriteSourceSizeW :number

Width of the trimmed sprite.

Type:
  • number
Source:
src/animation/Frame.js line 109

spriteSourceSizeX :number

X position of the trimmed sprite inside original sprite.

Type:
  • number
Source:
src/animation/Frame.js line 97

spriteSourceSizeY :number

Y position of the trimmed sprite inside original sprite.

Type:
  • number
Source:
src/animation/Frame.js line 103

trimmed :boolean

Was it trimmed when packed?

Type:
  • boolean
Source:
src/animation/Frame.js line 81

width :number

Width of the frame.

Type:
  • number
Source:
src/animation/Frame.js line 39

x :number

X position within the image to cut from.

Type:
  • number
Source:
src/animation/Frame.js line 29

y :number

Y position within the image to cut from.

Type:
  • number
Source:
src/animation/Frame.js line 34

Methods

clone()

Clones this Frame into a new Phaser.Frame object and returns it. Note that all properties are cloned, including the name and index.

Source:
src/animation/Frame.js line 182
Returns:

An exact copy of this Frame object.

Type
Phaser.Frame

getRect( [out])

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.

Source:
src/animation/Frame.js line 205
Returns:

A rectangle.

Type
Phaser.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.

Source:
src/animation/Frame.js line 131

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:
src/animation/Frame.js line 152