Class: GameObjectCreator

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.


new GameObjectCreator(scene)

Parameters:
Name Type Description
scene Phaser.Scene

The Scene to which this Game Object Factory belongs.

Since: 3.0.0
Source: src/gameobjects/GameObjectCreator.js (Line 11)

Members


<protected> displayList :Phaser.GameObjects.DisplayList

A reference to the Scene Display List.

Type:
Since: 3.0.0
Source: src/gameobjects/GameObjectCreator.js (Line 53)

<protected> scene :Phaser.Scene

The Scene to which this Game Object Creator belongs.

Type:
Since: 3.0.0
Source: src/gameobjects/GameObjectCreator.js (Line 33)

<protected> systems :Phaser.Scenes.Systems

A reference to the Scene.Systems.

Type:
Since: 3.0.0
Source: src/gameobjects/GameObjectCreator.js (Line 43)

<protected> updateList; :Phaser.GameObjects.UpdateList

A reference to the Scene Update List.

Type:
Since: 3.0.0
Source: src/gameobjects/GameObjectCreator.js (Line 63)

Methods


bitmapText(config [, addToScene])

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 Argument 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.

Since: 3.0.0
Source: src/gameobjects/bitmaptext/static/BitmapTextCreator.js (Line 13)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.BitmapText

blitter(config [, addToScene])

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 Argument 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.

Since: 3.0.0
Source: src/gameobjects/blitter/BlitterCreator.js (Line 12)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.Blitter

container(config [, addToScene])

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 Argument 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.

Since: 3.4.0
Source: src/gameobjects/container/ContainerCreator.js (Line 13)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.Container

dynamicBitmapText(config [, addToScene])

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 Argument 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.

Since: 3.0.0 ²
Source: src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCreator.js (Line 12)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.DynamicBitmapText

graphics(config [, addToScene])

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 Argument 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.

Since: 3.0.0
Source: src/gameobjects/graphics/GraphicsCreator.js (Line 10)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.Graphics

group(config)

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.

Since: 3.0.0
Source: src/gameobjects/group/GroupCreator.js (Line 10)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.Group

image(config [, addToScene])

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 Argument 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.

Since: 3.0.0
Source: src/gameobjects/image/ImageCreator.js (Line 12)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.Image

mesh(config [, addToScene])

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 Argument 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.

Since: 3.0.0
Source: src/gameobjects/mesh/MeshCreator.js (Line 13)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.Mesh

particles(config [, addToScene])

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 Argument 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.

Since: 3.0.0
Source: src/gameobjects/particles/ParticleManagerCreator.js (Line 12)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.Particles.ParticleEmitterManager

quad(config [, addToScene])

Creates a new Quad Game Object and returns it.

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

Parameters:
Name Type Argument 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.

Since: 3.0.0
Source: src/gameobjects/quad/QuadCreator.js (Line 12)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.Quad

renderTexture(config [, addToScene])

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 Argument 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.

Since: 3.2.0
Source: src/gameobjects/rendertexture/RenderTextureCreator.js (Line 12)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.RenderTexture

shader(config [, addToScene])

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 Argument 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.

Since: 3.17.0
Source: src/gameobjects/shader/ShaderCreator.js (Line 12)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.Shader

sprite(config [, addToScene])

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 Argument 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.

Since: 3.0.0
Source: src/gameobjects/sprite/SpriteCreator.js (Line 13)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.Sprite

sprite3D(config [, addToScene])

Creates a new Sprite3D Game Object and returns it.

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

Parameters:
Name Type Argument 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.

Since: 3.0.0
Source: plugins/camera3d/src/sprite3d/Sprite3DCreator.js (Line 13)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.Sprite3D

sprite3D(config [, addToScene])

Creates a new Sprite3D Game Object and returns it.

Parameters:
Name Type Argument 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.

Since: 3.0.0
Source: plugins/camera3d/src/Camera3DPlugin.js (Line 91)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.Sprite3D

text(config [, addToScene])

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 Argument 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.

Since: 3.0.0
Source: src/gameobjects/text/static/TextCreator.js (Line 12)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.Text

tilemap( [config])

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 Argument Description
config Phaser.Types.Tilemaps.TilemapConfig <optional>

The config options for the Tilemap.

Since: 3.0.0
Source: src/tilemaps/TilemapCreator.js (Line 10)
Returns:
Type
Phaser.Tilemaps.Tilemap

tileSprite(config [, addToScene])

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 Argument 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.

Since: 3.0.0
Source: src/gameobjects/tilesprite/TileSpriteCreator.js (Line 12)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.TileSprite

tween(config)

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 Phaser.Types.Tweens.TweenBuilderConfig | object

The Tween configuration.

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 1617)
Returns:

The Tween that was created.

Type
Phaser.Tweens.Tween

video(config [, addToScene])

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 Argument 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.

Since: 3.20.0
Source: src/gameobjects/video/VideoCreator.js (Line 12)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.Video

zone(config)

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.

Since: 3.0.0
Source: src/gameobjects/zone/ZoneCreator.js (Line 11)
Returns:

The Game Object that was created.

Type
Phaser.GameObjects.Zone