Class: Resource

PIXI.Resource

Base resource class for textures that manages validation and uploading, depending on its type.

Uploading of a base texture to the GPU is required.

new PIXI.Resource (width, height)

Name Type Default Description
width 0

Width of the resource

height 0

Height of the resource

Members

destroyed boolean readonly

If resource has been destroyed.

Default Value:
  • false

height number readonly

The height of the resource.

internal boolean

true if resource is created by BaseTexture useful for doing cleanup with BaseTexture destroy and not cleaning up resources that were created externally.

valid boolean readonly

Has been validated

width number readonly

The width of the resource.

_height number protected

Internal height of the resource.

_width number protected

Internal width of the resource.

Methods

PIXI.Resource.test (source, extension) boolean static

Abstract, used to auto-detect resource type.

Name Type Attributes Description
source unknown

The source object

extension string <optional>

The extension of source, if set

Returns:
Type Description
boolean

bind (baseTexture) void

Bind to a parent BaseTexture

Name Type Description
baseTexture PIXI.BaseTexture

Parent texture

destroy () void

Call when destroying resource, unbind any BaseTexture object before calling this method, as reference counts are maintained internally.

dispose () void

Clean up anything, this happens when destroying is ready.

resize (width, height) void

Trigger a resize event

Name Type Description
width number

X dimension

height number

Y dimension

style (renderer, baseTexture, glTexture) boolean

Set the style, optional to override

Name Type Description
renderer PIXI.Renderer

yeah, renderer!

baseTexture PIXI.BaseTexture

the texture

glTexture PIXI.GLTexture

texture instance for this webgl context

Returns:
Type Description
boolean
  • true is success

unbind (baseTexture) void

Unbind to a parent BaseTexture

Name Type Description
baseTexture PIXI.BaseTexture

Parent texture

update () void

Has been updated trigger event.

upload (renderer, baseTexture, glTexture) boolean abstract

Uploads the texture or returns false if it cant for some reason. Override this.

Name Type Description
renderer PIXI.Renderer

yeah, renderer!

baseTexture PIXI.BaseTexture

the texture

glTexture PIXI.GLTexture

texture instance for this webgl context

Returns:
Type Description
boolean
  • true is success

load () Promise<PIXI.Resource> protected

This can be overridden to start preloading a resource or do any other prepare step.

Returns:
Type Description
Promise<PIXI.Resource> Handle the validate event