Class

Sprite

Sprite(textureopt)

A sprite

Constructor

new Sprite(textureopt)

Draw 2D textured element efficiently.
Parameters:
Name Type Attributes Default Description
texture TextureInterface <optional>
null Can be a Texture or a TextureVideo

View Source Objects/Sprite.js, line 13

Extends

Methods

draw(renderTarget)

Draw the element
Parameters:
Name Type Description
renderTarget RenderTarget Renderer who called this method
Overrides:

View Source Objects/Sprite.js, line 105

getBlendMode() → {BlendMode}

Get sprite's blend mode

View Source Objects/Sprite.js, line 169

A BlendMode instance
BlendMode

getColor() → {Color}

Get sprite's color

View Source Objects/Sprite.js, line 178

A Color instance
Color

getCustomProgram() → (nullable) {Program}

Get program

View Source Objects/Sprite.js, line 187

A Program instance or null if the sprite use the default program
Program

getSize() → {Array.<number>}

Get size

View Source Objects/Sprite.js, line 196

An array with index 0 for size on X and index 1 for size on y
Array.<number>

getTexture() → {TextureInterface}

Get texture

View Source Objects/Sprite.js, line 205

A texture

getTextureRect() → {Array.<number>}

Get texture's area to show

View Source Objects/Sprite.js, line 214

An array representing area to show (x, y, w, h)
Array.<number>

setBlendMode(blendMode) → {Sprite}

Set blend mode to use
Parameters:
Name Type Description
blendMode BlendMode A BlendMode instance

View Source Objects/Sprite.js, line 79

A reference to the instance
Sprite

setColor(r, g, b, aopt) → {Sprite}

Set program to use
Parameters:
Name Type Attributes Default Description
r number Red color in the range [0-255]
g number Green color in the range [0-255]
b number Blue color in the range [0-255]
a number <optional>
255 Opacity in the range [0-255]

View Source Objects/Sprite.js, line 94

A reference to the instance
Sprite

setCustomProgram(program) → {Sprite}

Set program to use
Parameters:
Name Type Description
program Program A Program instance

View Source Objects/Sprite.js, line 117

A reference to the instance
Sprite

setSize(x, y) → {Sprite}

Set sprite's size
Parameters:
Name Type Description
x number Size on X
y number Size on Y

View Source Objects/Sprite.js, line 130

A reference to the instance
Sprite

setTexture(texture) → {Sprite}

Set texture to use
Parameters:
Name Type Description
texture TextureInterface Can be a Texture or a TextureVideo

View Source Objects/Sprite.js, line 143

A reference to the instance
Sprite

setTextureRect(x, y, w, h) → {Sprite}

Set texture's area to show
Parameters:
Name Type Description
x number Start position on x
y number Start position on y
w number Area's width
h number Area's height

View Source Objects/Sprite.js, line 158

A reference to the instance
Sprite

visit(renderTarget) → {boolean}

Visit the node and his children
Parameters:
Name Type Description
renderTarget RenderTarget Renderer who called this method
Inherited From:

View Source Objects/Drawable.js, line 23

True if visit was successful, otherwise false
boolean