Phaser API Documentation

  Version: 
registerFileType(key, callback, [addToScene])

Description:

Registers a new file type with the global File Types Manager, making it available to all Loader Plugins created after this.

This is usually called from within your Plugin code and is a helpful short-cut for creating new loader file types.

The key is the property that will be injected into the Loader Plugin and used to load the files. For example:

this.plugins.registerFileType('wad', doomWadLoaderCallback);
// later in your preload code:
this.load.wad();

The callback is what is called when the loader tries to load a file matching the given key. It's important to understand that the callback is invoked within the context of the LoaderPlugin. In this context there are several properties / methods available to use:

this.addFile - A method to add the new file to the load queue. this.scene - The Scene that owns the Loader Plugin instance.

See the LoaderPlugin class for more details. Any public property or method listed is available from your callback under this.

Parameters:

name type arguments description
key string

The key of the Game Object that the given callbacks will create, i.e. image, sprite.

callback function

The callback to invoke when the Game Object Factory is called.

addToScene Phaser.Scene <optional>

Optionally add this file type into the Loader Plugin owned by the given Scene.

Since: 3.8.0