Phaser API Documentation

  Version: 
Filter
This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord

Phaser . GameObjects . GameObjectCreator

This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord

Phaser . GameObjects . GameObjectCreator

The Game Object Creator is a Scene plugin that allows you to quickly create many common types of Game Objects and return them. Unlike the Game Object Factory, they are not automatically added to the Scene.

Game Objects directly register themselves with the Creator and inject their own creation methods into the class.

Constructor:

new GameObjectCreator(scene)

Parameters:

name type description
scene Phaser.Scene

The Scene to which this Game Object Factory belongs.

Since: 3.0.0

Members

<protected> displayList: Phaser.GameObjects.DisplayList
Focus
Focus

Description:

A reference to the Scene Display List.

Type:
Since: 3.0.0
Focus
Focus
<protected> events: Phaser.Events.EventEmitter
Focus
Focus

Description:

A reference to the Scene Event Emitter.

Type:
Since: 3.50.0
Focus
Focus
<protected> scene: Phaser.Scene
Focus
Focus

Description:

The Scene to which this Game Object Creator belongs.

Type:
Since: 3.0.0
Focus
Focus
<protected> systems: Phaser.Scenes.Systems
Focus
Focus

Description:

A reference to the Scene.Systems.

Type:
Since: 3.0.0
Focus
Focus
<protected> updateList: Phaser.GameObjects.UpdateList
Focus
Focus

Description:

A reference to the Scene Update List.

Type:
Since: 3.0.0
Focus
Focus

Methods

bitmapText(config, [addToScene])
Focus
Focus

Description:

Creates a new Bitmap Text Game Object and returns it.

Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser.

Parameters:

name type arguments description
config Phaser.Types.GameObjects.BitmapText.BitmapTextConfig

The configuration object this Game Object will use to create itself.

addToScene boolean <optional>

Add this Game Object to the Scene after creating it? If set this argument overrides the add property in the config object.

Returns:
Description:

The Game Object that was created.

Examples:
Focus
Focus
blitter(config, [addToScene])
Focus
Focus

Description:

Creates a new Blitter Game Object and returns it.

Note: This method will only be available if the Blitter Game Object has been built into Phaser.

Parameters:

name type arguments description
config object

The configuration object this Game Object will use to create itself.

addToScene boolean <optional>

Add this Game Object to the Scene after creating it? If set this argument overrides the add property in the config object.

Returns:
Description:

The Game Object that was created.

Examples:
Since: 3.0.0
Focus
Focus
<private> boot()
Focus
Focus

Description:

This method is called automatically, only once, when the Scene is first created. Do not invoke it directly.

Examples:
Since: 3.5.1
Focus
Focus
container(config, [addToScene])
Focus
Focus

Description:

Creates a new Container Game Object and returns it.

Note: This method will only be available if the Container Game Object has been built into Phaser.

Parameters:

name type arguments description
config object

The configuration object this Game Object will use to create itself.

addToScene boolean <optional>

Add this Game Object to the Scene after creating it? If set this argument overrides the add property in the config object.

Returns:
Description:

The Game Object that was created.

Examples:
Focus
Focus
<private> destroy()
Focus
Focus

Description:

The Scene that owns this plugin is being destroyed. We need to shutdown and then kill off all external references.

Examples:
Since: 3.0.0
Focus
Focus
dynamicBitmapText(config, [addToScene])
Focus
Focus

Description:

Creates a new Dynamic Bitmap Text Game Object and returns it.

Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser.

Parameters:

name type arguments description
config Phaser.Types.GameObjects.BitmapText.BitmapTextConfig

The configuration object this Game Object will use to create itself.

addToScene boolean <optional>

Add this Game Object to the Scene after creating it? If set this argument overrides the add property in the config object.

Returns:
Description:

The Game Object that was created.

Examples:
Focus
Focus
graphics(config, [addToScene])
Focus
Focus

Description:

Creates a new Graphics Game Object and returns it.

Note: This method will only be available if the Graphics Game Object has been built into Phaser.

Parameters:

name type arguments description
config object

The configuration object this Game Object will use to create itself.

addToScene boolean <optional>

Add this Game Object to the Scene after creating it? If set this argument overrides the add property in the config object.

Returns:
Description:

The Game Object that was created.

Examples:
Since: 3.0.0
Focus
Focus
group(config)
Focus
Focus

Description:

Creates a new Group Game Object and returns it.

Note: This method will only be available if the Group Game Object has been built into Phaser.

Parameters:

name type description
config Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig

The configuration object this Game Object will use to create itself.

Returns:
Description:

The Game Object that was created.

Examples:
Since: 3.0.0
Focus
Focus
image(config, [addToScene])
Focus
Focus

Description:

Creates a new Image Game Object and returns it.

Note: This method will only be available if the Image Game Object has been built into Phaser.

Parameters:

name type arguments description
config object

The configuration object this Game Object will use to create itself.

addToScene boolean <optional>

Add this Game Object to the Scene after creating it? If set this argument overrides the add property in the config object.

Returns:
Description:

The Game Object that was created.

Examples:
Since: 3.0.0
Focus
Focus
layer(config, [addToScene])
Focus
Focus

Description:

Creates a new Layer Game Object and returns it.

Note: This method will only be available if the Layer Game Object has been built into Phaser.

Parameters:

name type arguments description
config object

The configuration object this Game Object will use to create itself.

addToScene boolean <optional>

Add this Game Object to the Scene after creating it? If set this argument overrides the add property in the config object.

Returns:
Description:

The Game Object that was created.

Examples:
Since: 3.50.0
Focus
Focus
mesh(config, [addToScene])
Focus
Focus

Description:

Creates a new Mesh Game Object and returns it.

Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser.

Parameters:

name type arguments description
config object

The configuration object this Game Object will use to create itself.

addToScene boolean <optional>

Add this Game Object to the Scene after creating it? If set this argument overrides the add property in the config object.

Returns:
Description:

The Game Object that was created.

Examples:
Since: 3.0.0
Focus
Focus
particles(config, [addToScene])
Focus
Focus

Description:

Creates a new Particle Emitter Manager Game Object and returns it.

Note: This method will only be available if the Particles Game Object has been built into Phaser.

Parameters:

name type arguments description
config object

The configuration object this Game Object will use to create itself.

addToScene boolean <optional>

Add this Game Object to the Scene after creating it? If set this argument overrides the add property in the config object.

Returns:
Description:

The Game Object that was created.

Examples:
Focus
Focus
pointlight(config, [addToScene])
Focus
Focus

Description:

Creates a new Point Light Game Object and returns it.

Note: This method will only be available if the Point Light Game Object has been built into Phaser.

Parameters:

name type arguments description
config object

The configuration object this Game Object will use to create itself.

addToScene boolean <optional>

Add this Game Object to the Scene after creating it? If set this argument overrides the add property in the config object.

Returns:
Description:

The Game Object that was created.

Examples:
Focus
Focus
renderTexture(config, [addToScene])
Focus
Focus

Description:

Creates a new Render Texture Game Object and returns it.

Note: This method will only be available if the Render Texture Game Object has been built into Phaser.

Parameters:

name type arguments description
config Phaser.Types.GameObjects.RenderTexture.RenderTextureConfig

The configuration object this Game Object will use to create itself.

addToScene boolean <optional>

Add this Game Object to the Scene after creating it? If set this argument overrides the add property in the config object.

Returns:
Description:

The Game Object that was created.

Examples:
Focus
Focus
rope(config, [addToScene])
Focus
Focus

Description:

Creates a new Rope Game Object and returns it.

Note: This method will only be available if the Rope Game Object and WebGL support have been built into Phaser.

Parameters:

name type arguments description
config object

The configuration object this Game Object will use to create itself.

addToScene boolean <optional>

Add this Game Object to the Scene after creating it? If set this argument overrides the add property in the config object.

Returns:
Description:

The Game Object that was created.

Examples:
Since: 3.23.0
Focus
Focus
shader(config, [addToScene])
Focus
Focus

Description:

Creates a new Shader Game Object and returns it.

Note: This method will only be available if the Shader Game Object and WebGL support have been built into Phaser.

Parameters:

name type arguments description
config object

The configuration object this Game Object will use to create itself.

addToScene boolean <optional>

Add this Game Object to the Scene after creating it? If set this argument overrides the add property in the config object.

Returns:
Description:

The Game Object that was created.

Examples:
Since: 3.17.0
Focus
Focus
<private> shutdown()
Focus
Focus

Description:

The Scene that owns this plugin is shutting down. We need to kill and reset all internal properties as well as stop listening to Scene events.

Examples:
Since: 3.0.0
Focus
Focus
sprite(config, [addToScene])
Focus
Focus

Description:

Creates a new Sprite Game Object and returns it.

Note: This method will only be available if the Sprite Game Object has been built into Phaser.

Parameters:

name type arguments description
config Phaser.Types.GameObjects.Sprite.SpriteConfig

The configuration object this Game Object will use to create itself.

addToScene boolean <optional>

Add this Game Object to the Scene after creating it? If set this argument overrides the add property in the config object.

Returns:
Description:

The Game Object that was created.

Examples:
Since: 3.0.0
Focus
Focus
<private> start()
Focus
Focus

Description:

This method is called automatically by the Scene when it is starting up. It is responsible for creating local systems, properties and listening for Scene events. Do not invoke it directly.

Examples:
Since: 3.5.0
Focus
Focus
text(config, [addToScene])
Focus
Focus

Description:

Creates a new Text Game Object and returns it.

Note: This method will only be available if the Text Game Object has been built into Phaser.

Parameters:

name type arguments description
config Phaser.Types.GameObjects.Text.TextConfig

The configuration object this Game Object will use to create itself.

addToScene boolean <optional>

Add this Game Object to the Scene after creating it? If set this argument overrides the add property in the config object.

Returns:
Description:

The Game Object that was created.

Examples:
Since: 3.0.0
Focus
Focus
tileSprite(config, [addToScene])
Focus
Focus

Description:

Creates a new TileSprite Game Object and returns it.

Note: This method will only be available if the TileSprite Game Object has been built into Phaser.

Parameters:

name type arguments description
config Phaser.Types.GameObjects.TileSprite.TileSpriteConfig

The configuration object this Game Object will use to create itself.

addToScene boolean <optional>

Add this Game Object to the Scene after creating it? If set this argument overrides the add property in the config object.

Returns:
Description:

The Game Object that was created.

Examples:
Focus
Focus
tilemap([config])
Focus
Focus

Description:

Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map data. For an empty map, you should specify tileWidth, tileHeight, width & height.

Parameters:

name type arguments description
config Phaser.Types.Tilemaps.TilemapConfig <optional>

The config options for the Tilemap.

Examples:
Since: 3.0.0
Focus
Focus
tween(config)
Focus
Focus

Description:

Creates a new Tween object and returns it.

Note: This method will only be available if Tweens have been built into Phaser.

Parameters:

name type description
config object | Phaser.Types.Tweens.TweenBuilderConfig

The Tween configuration.

Returns:
Description:

The Tween that was created.

Examples:
Since: 3.0.0
Focus
Focus
video(config, [addToScene])
Focus
Focus

Description:

Creates a new Video Game Object and returns it.

Note: This method will only be available if the Video Game Object has been built into Phaser.

Parameters:

name type arguments description
config object

The configuration object this Game Object will use to create itself.

addToScene boolean <optional>

Add this Game Object to the Scene after creating it? If set this argument overrides the add property in the config object.

Returns:
Description:

The Game Object that was created.

Examples:
Since: 3.20.0
Focus
Focus
zone(config)
Focus
Focus

Description:

Creates a new Zone Game Object and returns it.

Note: This method will only be available if the Zone Game Object has been built into Phaser.

Parameters:

name type description
config object

The configuration object this Game Object will use to create itself.

Returns:
Description:

The Game Object that was created.

Examples:
Since: 3.0.0
Focus
Focus