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:
-
baseTextureBaseTextureThe 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:
-
destroyBaseBoolWhether to destroy the base texture as well
emit
-
eventName -
data
Emit an event to all registered event listeners.
Parameters:
-
eventNameStringThe name of the event.
-
dataDynamic
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:
-
canvasCanvasThe canvas element source of the texture
-
scaleModeIntShould 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:
-
frameIdStringThe 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:
-
imageUrlStringThe image url of the texture
-
crossoriginBoolWhether requests should be treated as crossorigin
-
scaleModeIntShould be one of the PIXI.scaleMode consts
Returns:
Texture
listeners
-
eventName
Return a list of assigned event listeners.
Parameters:
-
eventNameStringThe 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:
-
eventNameStringName of the event.
-
callbackFunctonCallback 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:
-
eventNameStringThe event you want to remove all listeners for.
removeTextureFromCache
-
id
Remove a texture from the textureCache.
Parameters:
-
idStringthe 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:
-
frameRectangleThe frame of the texture to set it to
