Class: GLSLFile

Phaser.Loader.FileTypes. GLSLFile

A single GLSL File suitable for loading by the Loader.

These are created when you use the Phaser.Loader.LoaderPlugin#glsl method and are not typically created directly.

For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#glsl.


new GLSLFile(loader, key [, url] [, xhrSettings])

Parameters:
Name Type Argument Description
loader Phaser.Loader.LoaderPlugin

A reference to the Loader that is responsible for this file.

key string | Phaser.Loader.FileTypes.TextFileConfig

The key to use for this file, or a file configuration object.

url string <optional>

The absolute or relative URL to load this file from. If undefined or null it will be set to <key>.txt, i.e. if key was "alien" then the URL will be "alien.txt".

xhrSettings XHRSettingsObject <optional>

Extra XHR Settings specifically for this file.

Since: 3.0.0
Source: src/loader/filetypes/GLSLFile.js (Line 23)

Extends

Members


bytesLoaded :number

Updated as the file loads.
Only set if loading via XHR.

Type:
  • number
Since: 3.0.0
Inherited From:
Default Value:
  • -1
Source: src/loader/File.js (Line 167)

bytesTotal :number

The total size of this file.
Set by onProgress and only if loading via XHR.

Type:
  • number
Since: 3.0.0
Inherited From:
Default Value:
  • 0
Source: src/loader/File.js (Line 156)

cache :Phaser.Cache.BaseCache|Phaser.Textures.TextureManager

A reference to the Cache, or Texture Manager, that is going to store this file if it loads.

Type:
Since: 3.7.0
Inherited From:
Source: src/loader/File.js (Line 56)

config :*

A config object that can be used by file types to store transitional data.

Type:
  • *
Since: 3.0.0
Inherited From:
Source: src/loader/File.js (Line 208)

crossOrigin :string|undefined

For CORs based loading.
If this is undefined then the File will check BaseLoader.crossOrigin and use that (if set)

Type:
  • string | undefined
Since: 3.0.0
Inherited From:
Source: src/loader/File.js (Line 189)

data :*

The processed file data, stored here after the file has loaded.

Type:
  • *
Since: 3.0.0
Inherited From:
Source: src/loader/File.js (Line 199)

key :string

Unique cache key (unique within its file type)

Type:
  • string
Since: 3.0.0
Inherited From:
Source: src/loader/File.js (Line 74)

<nullable> linkFile :Phaser.Loader.File

Does this file have an associated linked file? Such as an image and a normal map.
Atlases and Bitmap Fonts use the multiFile, because those files need loading together but aren't
actually bound by data, where-as a linkFile is.

Type:
Since: 3.7.0
Inherited From:
Source: src/loader/File.js (Line 227)

loader :Phaser.Loader.LoaderPlugin

A reference to the Loader that is going to load this file.

Type:
Since: 3.0.0
Inherited From:
Source: src/loader/File.js (Line 47)

<nullable> multiFile :Phaser.Loader.MultiFile

If this is a multipart file, i.e. an atlas and its json together, then this is a reference
to the parent MultiFile. Set and used internally by the Loader or specific file types.

Type:
Since: 3.7.0
Inherited From:
Source: src/loader/File.js (Line 217)

percentComplete :number

A percentage value between 0 and 1 indicating how much of this file has loaded.
Only set if loading via XHR.

Type:
  • number
Since: 3.0.0
Inherited From:
Default Value:
  • -1
Source: src/loader/File.js (Line 178)

src :string

The final URL this file will load from, including baseURL and path.
Set automatically when the Loader calls 'load' on this file.

Type:
  • string
Since: 3.0.0
Inherited From:
Source: src/loader/File.js (Line 114)

state :integer

The current state of the file. One of the FILE_CONST values.

Type:
  • integer
Since: 3.0.0
Inherited From:
Source: src/loader/File.js (Line 147)

type :string

The file type string (image, json, etc) for sorting within the Loader.

Type:
  • string
Since: 3.0.0
Inherited From:
Source: src/loader/File.js (Line 65)

url :string

The URL of the file, not including baseURL.
Automatically has Loader.path prepended to it.

Type:
  • string
Since: 3.0.0
Inherited From:
Source: src/loader/File.js (Line 95)

<nullable> xhrLoader :XMLHttpRequest

The XMLHttpRequest instance (as created by XHR Loader) that is loading this File.

Type:
  • XMLHttpRequest
Since: 3.0.0
Inherited From:
Source: src/loader/File.js (Line 138)

xhrSettings :XHRSettingsObject

The merged XHRSettings for this file.

Type:
Since: 3.0.0
Inherited From:
Source: src/loader/File.js (Line 124)

Methods


addToCache()

Adds this file to its target cache upon successful loading and processing.
This method is often overridden by specific file types.

Since: 3.7.0
Inherited From:
Source: src/loader/File.js (Line 434)

destroy()

Destroy this File and any references it holds.

Since: 3.7.0
Inherited From:
Source: src/loader/File.js (Line 525)

hasCacheConflict()

Checks if a key matching the one used by this file exists in the target Cache or not.
This is called automatically by the LoaderPlugin to decide if the file can be safely
loaded or will conflict.

Since: 3.7.0
Inherited From:
Source: src/loader/File.js (Line 419)
Returns:

true if adding this file will cause a conflict, otherwise false.

Type
boolean

load()

Called by the Loader, starts the actual file downloading.
During the load the methods onLoad, onError and onProgress are called, based on the XHR events.
You shouldn't normally call this method directly, it's meant to be invoked by the Loader.

Since: 3.0.0
Inherited From:
Source: src/loader/File.js (Line 270)

onError(event)

Called if the file errors while loading, is sent a DOM ProgressEvent.

Parameters:
Name Type Description
event ProgressEvent

The DOM ProgressEvent that resulted from this error.

Since: 3.0.0
Inherited From:
Source: src/loader/File.js (Line 331)

onLoad(xhr, event)

Called when the file finishes loading, is sent a DOM ProgressEvent.

Parameters:
Name Type Description
xhr XMLHttpRequest

The XMLHttpRequest that caused this onload event.

event ProgressEvent

The DOM ProgressEvent that resulted from this load.

Since: 3.0.0
Inherited From:
Source: src/loader/File.js (Line 307)

onProcess()

Called automatically by Loader.nextFile.
This method controls what extra work this File does with its loaded data.

Since: 3.7.0
Overrides:
Source: src/loader/filetypes/GLSLFile.js (Line 75)

onProcessComplete()

Called when the File has completed processing.
Checks on the state of its multifile, if set.

Since: 3.7.0
Inherited From:
Source: src/loader/File.js (Line 381)

onProcessError()

Called when the File has completed processing but it generated an error.
Checks on the state of its multifile, if set.

Since: 3.7.0
Inherited From:
Source: src/loader/File.js (Line 400)

onProgress(event)

Called during the file load progress. Is sent a DOM ProgressEvent.

Parameters:
Name Type Description
event ProgressEvent

The DOM ProgressEvent.

Since: 3.0.0
Inherited From:
Source: src/loader/File.js (Line 346)

pendingDestroy()

Called once the file has been added to its cache and is now ready for deletion from the Loader.
It will emit a filecomplete event from the LoaderPlugin.

Since: 3.7.0
Inherited From:
Source: src/loader/File.js (Line 503)
Fires:

resetXHR()

Resets the XHRLoader instance this file is using.

Since: 3.0.0
Inherited From:
Source: src/loader/File.js (Line 254)

Links this File with another, so they depend upon each other for loading and processing.

Parameters:
Name Type Description
fileB Phaser.Loader.File

The file to link to this one.

Since: 3.7.0
Inherited From:
Source: src/loader/File.js (Line 239)

Events


fileCompleteEvent

You can listen for this event from the LoaderPlugin. It is dispatched every time
a file loads and is sent 3 arguments, which allow you to identify the file:

this.load.on('filecomplete', function (key, type, data) {
    // Your handler code
});
Parameters:
Name Type Description
key string

The key of the file that just loaded and finished processing.

type string

The type of the file that just loaded and finished processing.

data any

The data of the file.

Inherited From:
Source: src/loader/File.js (Line 451)

singleFileCompleteEvent

You can listen for this event from the LoaderPlugin. It is dispatched only once per
file and you have to use a special listener handle to pick it up.

The string of the event is based on the file type and the key you gave it, split up
using hyphens.

For example, if you have loaded an image with a key of monster, you can listen for it
using the following:

this.load.on('filecomplete-image-monster', function (key, type, data) {
    // Your handler code
});

Or, if you have loaded a texture atlas with a key of Level1:

this.load.on('filecomplete-atlas-Level1', function (key, type, data) {
    // Your handler code
});

Or, if you have loaded a sprite sheet with a key of Explosion and a prefix of GAMEOVER:

this.load.on('filecomplete-spritesheet-GAMEOVERExplosion', function (key, type, data) {
    // Your handler code
});
Parameters:
Name Type Description
data any

The data of the file.

Inherited From:
Source: src/loader/File.js (Line 467)