Texture Class
A texture stores the information that represents an image or part of an image. It cannot be added to the display list directly. Instead use it as the texture for a PIXI.Sprite. If no frame is provided then the whole image is used.
Constructor
Texture
-
baseTexture
-
[frame]
-
[crop]
-
[trim]
Parameters:
-
baseTexture
BaseTextureThe base texture source to create the texture from
-
[frame]
Rectangle optionalThe rectangle frame of the texture to show
-
[crop]
Rectangle optionalThe area of original texture
-
[trim]
Rectangle optionalTrimmed texture rectangle
Item Index
Methods
- addTextureToCache static
- destroy
- emit
- fromCanvas static
- fromFrame static
- fromImage static
- listeners
- off
- on
- once
- removeAllListeners
- removeTextureFromCache static
- setFrame
Methods
addTextureToCache
-
texture
-
id
Adds a texture to the textureCache.
destroy
-
destroyBase
Destroys this texture
Parameters:
-
destroyBase
BoolWhether to destroy the base texture as well
emit
-
eventName
-
data
Emit an event to all registered event listeners.
Parameters:
-
eventName
StringThe name of the event.
-
data
Dynamic
Returns:
Indication if we've emitted an event.
fromCanvas
-
canvas
-
scaleMode
Helper function that returns a texture based on a canvas element If the canvas is not in the texture cache it will be created and loaded
Parameters:
-
canvas
CanvasThe canvas element source of the texture
-
scaleMode
IntShould be one of the PIXI.scaleMode consts
Returns:
Texture
fromFrame
-
frameId
Helper function that returns a texture based on a frame id If the frame id is not in the texture cache an error will be thrown
Parameters:
-
frameId
StringThe frame id of the texture
Returns:
Texture
fromImage
-
imageUrl
-
crossorigin
-
scaleMode
Helper function that returns a texture based on an image url If the image is not in the texture cache it will be created and loaded
Parameters:
-
imageUrl
StringThe image url of the texture
-
crossorigin
BoolWhether requests should be treated as crossorigin
-
scaleMode
IntShould be one of the PIXI.scaleMode consts
Returns:
Texture
listeners
-
eventName
Return a list of assigned event listeners.
Parameters:
-
eventName
StringThe events that should be listed.
Returns:
An array of listener functions
off
-
eventName
-
callback
Remove event listeners.
on
-
eventName
-
callback
Register a new EventListener for the given event.
Parameters:
-
eventName
StringName of the event.
-
callback
FunctonCallback function.
once
-
eventName
-
callback
Add an EventListener that's only called once.
removeAllListeners
-
eventName
Remove all listeners or only the listeners for the specified event.
Parameters:
-
eventName
StringThe event you want to remove all listeners for.
removeTextureFromCache
-
id
Remove a texture from the textureCache.
Parameters:
-
id
Stringthe id of the texture to be removed
Returns:
the texture that was removed
setFrame
-
frame
Specifies the region of the baseTexture that this texture will use.
Parameters:
-
frame
RectangleThe frame of the texture to set it to