Class: Resource

PIXI.resources.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.resources.Resource (width, height)

Name Type Default Description
width number 0 optional

Width of the resource

height number 0 optional

Height of the resource

Members

_height number protected

Internal height of the resource

_width number protected

Internal width of the resource

destroyed boolean readonly

If resource has been destroyed

Default Value:
  • false

height number readonly

The height of the resource.

internal boolean protected

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.

Methods

bind (baseTexture)

Bind to a parent BaseTexture

Name Type Description
baseTexture PIXI.BaseTexture

Parent texture

destroy ()

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

dispose () protected

Clean up anything, this happens when destroying is ready.

load ()Promise.<void> protected

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

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

resize (width, height)

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)

Unbind to a parent BaseTexture

Name Type Description
baseTexture PIXI.BaseTexture

Parent texture

update ()

Has been updated trigger event

upload (renderer, baseTexture, glTexture)boolean

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