API Docs for: 2.2.1
Show:

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 BaseTexture

    The base texture source to create the texture from

  • [frame] Rectangle optional

    The rectangle frame of the texture to show

  • [crop] Rectangle optional

    The area of original texture

  • [trim] Rectangle optional

    Trimmed texture rectangle

Methods

addTextureToCache

(
  • texture
  • id
)
static

Adds a texture to the textureCache.

Parameters:

  • texture Texture
  • id String

    the id that the texture will be stored against.

destroy

(
  • destroyBase
)

Destroys this texture

Parameters:

  • destroyBase Bool

    Whether to destroy the base texture as well

emit

(
  • eventName
  • data
)
Bool

Emit an event to all registered event listeners.

Parameters:

  • eventName String

    The name of the event.

  • data Dynamic

Returns:

Bool:

Indication if we've emitted an event.

fromCanvas

(
  • canvas
  • scaleMode
)
static

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 Canvas

    The canvas element source of the texture

  • scaleMode Int

    Should be one of the PIXI.scaleMode consts

Returns:

Texture

fromFrame

(
  • frameId
)
static

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 String

    The frame id of the texture

Returns:

Texture

fromImage

(
  • imageUrl
  • crossorigin
  • scaleMode
)
static

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 String

    The image url of the texture

  • crossorigin Bool

    Whether requests should be treated as crossorigin

  • scaleMode Int

    Should be one of the PIXI.scaleMode consts

Returns:

Texture

listeners

(
  • eventName
)
Array

Return a list of assigned event listeners.

Parameters:

  • eventName String

    The events that should be listed.

Returns:

Array:

An array of listener functions

off

(
  • eventName
  • callback
)

Remove event listeners.

Parameters:

  • eventName String

    The event we want to remove.

  • callback Function

    The listener that we need to find.

on

(
  • eventName
  • callback
)

Register a new EventListener for the given event.

Parameters:

  • eventName String

    Name of the event.

  • callback Functon

    Callback function.

once

(
  • eventName
  • callback
)

Add an EventListener that's only called once.

Parameters:

  • eventName String

    Name of the event.

  • callback Function

    Callback function.

removeAllListeners

(
  • eventName
)

Remove all listeners or only the listeners for the specified event.

Parameters:

  • eventName String

    The event you want to remove all listeners for.

removeTextureFromCache

(
  • id
)
Texture static

Remove a texture from the textureCache.

Parameters:

  • id String

    the id of the texture to be removed

Returns:

Texture:

the texture that was removed

setFrame

(
  • frame
)

Specifies the region of the baseTexture that this texture will use.

Parameters:

  • frame Rectangle

    The frame of the texture to set it to