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 |
Extends
Methods
draw(renderTarget)
Draw the element
Parameters:
Name | Type | Description |
---|---|---|
renderTarget |
RenderTarget | Renderer who called this method |
- Overrides:
getCustomProgram() → (nullable) {Program}
Get program
A Program instance or null if the sprite use the default program
getSize() → {Array.<number>}
Get size
An array with index 0 for size on X and index 1 for size on y
Array.<number>
getTextureRect() → {Array.<number>}
Get texture's area to show
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 |
A reference to the instance
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] |
A reference to the instance
setCustomProgram(program) → {Sprite}
Set program to use
Parameters:
Name | Type | Description |
---|---|---|
program |
Program | A Program instance |
A reference to the instance
setSize(x, y) → {Sprite}
Set sprite's size
Parameters:
Name | Type | Description |
---|---|---|
x |
number | Size on X |
y |
number | Size on Y |
A reference to the instance
setTexture(texture) → {Sprite}
Set texture to use
Parameters:
Name | Type | Description |
---|---|---|
texture |
TextureInterface | Can be a Texture or a TextureVideo |
A reference to the instance
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 |
A reference to the instance
visit(renderTarget) → {boolean}
Visit the node and his children
Parameters:
Name | Type | Description |
---|---|---|
renderTarget |
RenderTarget | Renderer who called this method |
- Inherited From:
True if visit was successful, otherwise false
boolean