PIXI. Sprite

new Sprite(texture)

The Sprite object is the base for all textured objects that are rendered to the screen

Parameters:
Name Type Description
texture PIXI.Texture

The texture for this sprite

Source - pixi/display/Sprite.js, line 5

Extends

Members

alpha :Number

The alpha value of this DisplayObject. A value of 1 is fully opaque. A value of 0 is transparent.
Please note that an object with an alpha value of 0 is skipped during the render pass.

The value of this property does not reflect any alpha values set further up the display list.
To obtain that value please see the worldAlpha property.

Inherited From:
Source - pixi/display/DisplayObject.js, line 63

anchor :Point

The anchor sets the origin point of the texture.
The default is 0,0 this means the texture's origin is the top left
Setting than anchor to 0.5,0.5 means the textures origin is centered
Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner

Source - pixi/display/Sprite.js, line 17

blendMode :Number

The blend mode to be applied to the sprite. Set to PIXI.blendModes.NORMAL to remove any blend mode.

Warning: You cannot have a blend mode and a filter active on the same Sprite. Doing so will render the sprite invisible.

Default Value:
  • PIXI.blendModes.NORMAL;
Source - pixi/display/Sprite.js, line 82

cacheAsBitmap :Boolean

Sets if this DisplayObject should be cached as a bitmap.

When invoked it will take a snapshot of the DisplayObject, as it is at that moment, and store it
in a RenderTexture. This is then used whenever this DisplayObject is rendered. It can provide a
performance benefit for complex, but static, DisplayObjects. I.e. those with lots of children.

Cached Bitmaps do not track their parents. If you update a property of this DisplayObject, it will not
re-generate the cached bitmap automatically. To do that you need to call DisplayObject.updateCache.

To remove a cached bitmap, set this property to null.

Inherited From:
Source - pixi/display/DisplayObject.js, line 763

<readonly> children :Array.<DisplayObject>

[read-only] The array of children of this container.

Type:
Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 17

exists :Boolean

Controls if this Sprite is processed by the core Phaser game loops and Group loops.

Default Value:
  • true
Source - pixi/display/Sprite.js, line 103

filterArea :Rectangle

The rectangular area used by filters when rendering a shader for this DisplayObject.

Inherited From:
Source - pixi/display/DisplayObject.js, line 195

filters :Array

Sets the filters for this DisplayObject. This is a WebGL only feature, and is ignored by the Canvas
Renderer. A filter is a shader applied to this DisplayObject. You can modify the placement of the filter
using DisplayObject.filterArea.

To remove filters, set this property to null.

Note: You cannot have a filter set, and a MULTIPLY Blend Mode active, at the same time. Setting a
filter will reset this DisplayObjects blend mode to NORMAL.

Inherited From:
Source - pixi/display/DisplayObject.js, line 710

height :Number

The height of the sprite, setting this will actually modify the scale to achieve the value set

Source - pixi/display/Sprite.js, line 144

hitArea :Rectangle|Circle|Ellipse|Polygon

This is the defined area that will pick up mouse / touch events. It is null by default.
Setting it is a neat way of optimising the hitTest function that the interactionManager will use (as it will not need to hit test all the children)

Type:
  • Rectangle | Circle | Ellipse | Polygon
Inherited From:
Source - pixi/display/DisplayObject.js, line 89

ignoreChildInput :Boolean

If ignoreChildInput is false it will allow this objects children to be considered as valid for Input events.

If this property is true then the children will not be considered as valid for Input events.

Note that this property isn't recursive: only immediate children are influenced, it doesn't scan further down.

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 26

mask :PIXIGraphics

Sets a mask for this DisplayObject. A mask is an instance of a Graphics object.
When applied it limits the visible area of this DisplayObject to the shape of the mask.
Under a Canvas renderer it uses shape clipping. Under a WebGL renderer it uses a Stencil Buffer.
To remove a mask, set this property to null.

Inherited From:
Source - pixi/display/DisplayObject.js, line 675

<readonly> parent :PIXIDisplayObjectContainer

The parent DisplayObjectContainer that this DisplayObject is a child of.
All DisplayObjects must belong to a parent in order to be rendered.
The root parent is the Stage object. This property is set automatically when the
DisplayObject is added to, or removed from, a DisplayObjectContainer.

Inherited From:
Source - pixi/display/DisplayObject.js, line 107

pivot :PIXIPoint

The pivot point of this DisplayObject that it rotates around. The values are expressed
in pixel values.

Inherited From:
Source - pixi/display/DisplayObject.js, line 43

position :PIXIPoint

The coordinates, in pixels, of this DisplayObject, relative to its parent container.

The value of this property does not reflect any positioning happening further up the display list.
To obtain that value please see the worldPosition property.

Inherited From:
Source - pixi/display/DisplayObject.js, line 20

renderable :Boolean

Should this DisplayObject be rendered by the renderer? An object with a renderable value of
false is skipped during the render pass.

Inherited From:
Source - pixi/display/DisplayObject.js, line 98

rotation :Number

The rotation of this DisplayObject. The value is given, and expressed, in radians, and is based on
a right-handed orientation.

The value of this property does not reflect any rotation happening further up the display list.
To obtain that value please see the worldRotation property.

Inherited From:
Source - pixi/display/DisplayObject.js, line 51

scale :PIXIPoint

The scale of this DisplayObject. A scale of 1:1 represents the DisplayObject
at its default size. A value of 0.5 would scale this DisplayObject by half, and so on.

The value of this property does not reflect any scaling happening further up the display list.
To obtain that value please see the worldScale property.

Inherited From:
Source - pixi/display/DisplayObject.js, line 31

shader :PhaserFilter

The shader that will be used to render this Sprite.
Set to null to remove a current shader.

Default Value:
  • null
Source - pixi/display/Sprite.js, line 93

texture :PIXI.Texture

The texture that the sprite is using

Source - pixi/display/Sprite.js, line 28

tint :Number

The tint applied to the sprite. This is a hex value. A value of 0xFFFFFF will remove any tint effect.

Default Value:
  • 0xFFFFFF
Source - pixi/display/Sprite.js, line 54

tintedTexture :Canvas

A canvas that contains the tinted version of the Sprite (in Canvas mode, WebGL doesn't populate this)

Default Value:
  • null
Source - pixi/display/Sprite.js, line 73

visible :Boolean

The visibility of this DisplayObject. A value of false makes the object invisible.
A value of true makes it visible. Please note that an object with a visible value of
false is skipped during the render pass. Equally a DisplayObject with visible false will
not render any of its children.

The value of this property does not reflect any visible values set further up the display list.
To obtain that value please see the worldVisible property.

Inherited From:
Source - pixi/display/DisplayObject.js, line 75

width :Number

The width of the sprite, setting this will actually modify the scale to achieve the value set

Source - pixi/display/Sprite.js, line 125

<readonly> worldAlpha :Number

The multiplied alpha value of this DisplayObject. A value of 1 is fully opaque. A value of 0 is transparent.
This value is the calculated total, based on the alpha values of all parents of this DisplayObjects
in the display list.

To obtain, and set, the local alpha value, see the alpha property.

Note: This property is only updated at the end of the updateTransform call, once per render. Until
that happens this property will contain values based on the previous frame. Be mindful of this if
accessing this property outside of the normal game flow, i.e. from an asynchronous event callback.

Inherited From:
Source - pixi/display/DisplayObject.js, line 119

<readonly> worldPosition :PIXIPoint

The coordinates, in pixels, of this DisplayObject within the world.

This property contains the calculated total, based on the positions of all parents of this
DisplayObject in the display list.

Note: This property is only updated at the end of the updateTransform call, once per render. Until
that happens this property will contain values based on the previous frame. Be mindful of this if
accessing this property outside of the normal game flow, i.e. from an asynchronous event callback.

Inherited From:
Source - pixi/display/DisplayObject.js, line 150

<readonly> worldRotation :Number

The rotation, in radians, of this DisplayObject.

This property contains the calculated total, based on the rotations of all parents of this
DisplayObject in the display list.

Note: This property is only updated at the end of the updateTransform call, once per render. Until
that happens this property will contain values based on the previous frame. Be mindful of this if
accessing this property outside of the normal game flow, i.e. from an asynchronous event callback.

Inherited From:
Source - pixi/display/DisplayObject.js, line 180

<readonly> worldScale :PIXIPoint

The global scale of this DisplayObject.

This property contains the calculated total, based on the scales of all parents of this
DisplayObject in the display list.

Note: This property is only updated at the end of the updateTransform call, once per render. Until
that happens this property will contain values based on the previous frame. Be mindful of this if
accessing this property outside of the normal game flow, i.e. from an asynchronous event callback.

Inherited From:
Source - pixi/display/DisplayObject.js, line 165

<readonly> worldTransform :PIXIMatrix

The current transform of this DisplayObject.

This property contains the calculated total, based on the transforms of all parents of this
DisplayObject in the display list.

Note: This property is only updated at the end of the updateTransform call, once per render. Until
that happens this property will contain values based on the previous frame. Be mindful of this if
accessing this property outside of the normal game flow, i.e. from an asynchronous event callback.

Inherited From:
Source - pixi/display/DisplayObject.js, line 135

worldVisible :Boolean

Indicates if this DisplayObject is visible, based on it, and all of its parents, visible property values.

Inherited From:
Source - pixi/display/DisplayObject.js, line 632

x :Number

The horizontal position of the DisplayObject, in pixels, relative to its parent.
If you need the world position of the DisplayObject, use DisplayObject.worldPosition instead.

Inherited From:
Source - pixi/display/DisplayObject.js, line 588

y :Number

The vertical position of the DisplayObject, in pixels, relative to its parent.
If you need the world position of the DisplayObject, use DisplayObject.worldPosition instead.

Inherited From:
Source - pixi/display/DisplayObject.js, line 610

Methods

addChild(child) → {PIXI.DisplayObject}

Adds a child to the container.

Parameters:
Name Type Description
child PIXI.DisplayObject

The DisplayObject to add to the container

Returns:

The child that was added.

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 42

addChildAt(child, index) → {PIXI.DisplayObject}

Adds a child to the container at a specified index. If the index is out of bounds an error will be thrown

Parameters:
Name Type Description
child PIXI.DisplayObject

The child to add

index Number

The index to place the child in

Returns:

The child that was added.

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 55

contains(child) → {Boolean}

Determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself.

Parameters:
Name Type Description
child PIXI.DisplayObject

-

Returns:
Boolean -
Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 449

getBounds(matrix) → {Rectangle}

Returns the bounds of the Sprite as a rectangle.
The bounds calculation takes the worldTransform into account.

It is important to note that the transform is not updated when you call this method.
So if this Sprite is the child of a Display Object which has had its transform
updated since the last render pass, those changes will not yet have been applied
to this Sprites worldTransform. If you need to ensure that all parent transforms
are factored into this getBounds operation then you should call updateTransform
on the root most object in this Sprites display list first.

Parameters:
Name Type Description
matrix Matrix

the transformation matrix of the sprite

Returns:
Rectangle -

the framing rectangle

Source - pixi/display/Sprite.js, line 199

getChildAt(index) → {PIXI.DisplayObject}

Returns the child at the specified index

Parameters:
Name Type Description
index Number

The index to get the child from

Returns:

The child at the given index, if any.

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 153

getChildIndex(child) → {Number}

Returns the index position of a child DisplayObject instance

Parameters:
Name Type Description
child PIXI.DisplayObject

The DisplayObject instance to identify

Returns:
Number -

The index position of the child display object to identify

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 112

getLocalBounds() → {Rectangle}

Retrieves the non-global local bounds of the Sprite as a rectangle. The calculation takes all visible children into consideration.

Returns:
Rectangle -

The rectangular bounding area

Source - pixi/display/Sprite.js, line 315

removeChild(child) → {PIXI.DisplayObject}

Removes a child from the container.

Parameters:
Name Type Description
child PIXI.DisplayObject

The DisplayObject to remove

Returns:

The child that was removed.

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 171

removeChildAt(index) → {PIXI.DisplayObject}

Removes a child from the specified index position.

Parameters:
Name Type Description
index Number

The index to get the child from

Returns:

The child that was removed.

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 191

removeChildren(beginIndex, endIndex)

Removes all children from this container that are within the begin and end indexes.

Parameters:
Name Type Description
beginIndex Number

The beginning position. Default value is 0.

endIndex Number

The ending position. Default value is size of the container.

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 213

setChildIndex(child, index)

Changes the position of an existing child in the display object container

Parameters:
Name Type Description
child PIXI.DisplayObject

The child DisplayObject instance for which you want to change the index number

index Number

The resulting index number for the child display object

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 132

setTexture(texture, destroy)

Sets the texture of the sprite. Be warned that this doesn't remove or destroy the previous
texture this Sprite was using.

Parameters:
Name Type Argument Default Description
texture PIXI.Texture

The PIXI texture that is displayed by the sprite

destroy Boolean <optional>
false

Call Texture.destroy on the current texture before replacing it with the new one?

Source - pixi/display/Sprite.js, line 163

swapChildren(child, child2)

Swaps the position of 2 Display Objects within this container.

Parameters:
Name Type Description
child PIXI.DisplayObject

-

child2 PIXI.DisplayObject

-

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 85
Phaser Copyright © 2012-2016 Photon Storm Ltd.
Documentation generated by JSDoc 3.4.3 on Thu Apr 13 2017 12:05:15 GMT-0700 (PDT) using the DocStrap template.