Skip to main content
Version: Phaser v4.0.0-rc.6

Blitter

A Blitter Game Object.

The Blitter Game Object is a special kind of container that creates, updates and manages Bob objects.

Bobs are designed for rendering speed rather than flexibility. They consist of a texture, or frame from a texture,

a position and an alpha value. You cannot scale or rotate them. They use a batched drawing method for speed

during rendering.

A Blitter Game Object has one texture bound to it. Bobs created by the Blitter can use any Frame from this

Texture to render with, but they cannot use any other Texture. It is this single texture-bind that allows

them their speed.

If you have a need to blast a large volume of frames around the screen then Blitter objects are well worth

investigating. They are especially useful for using as a base for your own special effects systems.

Constructor

new Blitter(scene, [x], [y], [texture], [frame])

Parameters

nametypeoptionaldefaultdescription
scenePhaser.SceneNoThe Scene to which this Game Object belongs. It can only belong to one Scene at any given time.
xnumberYes0The x coordinate of this Game Object in world space.
ynumberYes0The y coordinate of this Game Object in world space.
texturestringYes"'__DEFAULT'"The key of the texture this Game Object will use for rendering. The Texture must already exist in the Texture Manager.
framestring | numberYes0The Frame of the Texture that this Game Object will use. Only set if the Texture has multiple frames, such as a Texture Atlas or Sprite Sheet.

Scope: static

Extends

Phaser.GameObjects.GameObject
Phaser.GameObjects.Components.Alpha
Phaser.GameObjects.Components.BlendMode
Phaser.GameObjects.Components.Depth
Phaser.GameObjects.Components.Lighting
Phaser.GameObjects.Components.Mask
Phaser.GameObjects.Components.RenderNodes
Phaser.GameObjects.Components.ScrollFactor
Phaser.GameObjects.Components.Size
Phaser.GameObjects.Components.Texture
Phaser.GameObjects.Components.Transform
Phaser.GameObjects.Components.Visible

Source: src/gameobjects/blitter/Blitter.js#L23
Since: 3.0.0

Inherited Members

From Phaser.GameObjects.Components.Alpha:

From Phaser.GameObjects.Components.BlendMode:

From Phaser.GameObjects.Components.Depth:

From Phaser.GameObjects.Components.Filters:

From Phaser.GameObjects.Components.Lighting:

From Phaser.GameObjects.Components.Mask:

From Phaser.GameObjects.Components.RenderNodes:

From Phaser.GameObjects.Components.ScrollFactor:

From Phaser.GameObjects.Components.Size:

From Phaser.GameObjects.Components.Texture:

From Phaser.GameObjects.Components.Transform:

From Phaser.GameObjects.Components.Visible:

From Phaser.GameObjects.GameObject:


Public Members

children

children: Phaser.Structs.List.<Phaser.GameObjects.Bob>

Description:

The children of this Blitter.

This List contains all of the Bob objects created by the Blitter.

Source: src/gameobjects/blitter/Blitter.js#L92
Since: 3.0.0


dirty

dirty: boolean

Description:

Is the Blitter considered dirty?

A 'dirty' Blitter has had its child count changed since the last frame.

Source: src/gameobjects/blitter/Blitter.js#L114
Since: 3.0.0


Inherited Methods

From Phaser.Events.EventEmitter:

From Phaser.GameObjects.Components.Alpha:

From Phaser.GameObjects.Components.BlendMode:

From Phaser.GameObjects.Components.Depth:

From Phaser.GameObjects.Components.Filters:

From Phaser.GameObjects.Components.Lighting:

From Phaser.GameObjects.Components.Mask:

From Phaser.GameObjects.Components.RenderNodes:

From Phaser.GameObjects.Components.RenderSteps:

From Phaser.GameObjects.Components.ScrollFactor:

From Phaser.GameObjects.Components.Size:

From Phaser.GameObjects.Components.Texture:

From Phaser.GameObjects.Components.Transform:

From Phaser.GameObjects.Components.Visible:

From Phaser.GameObjects.GameObject:


Public Methods

childCanRender

<instance> childCanRender(child)

Description:

Checks if the given child can render or not, by checking its visible and alpha values.

Parameters:

nametypeoptionaldescription
childPhaser.GameObjects.BobNoThe Bob to check for rendering.

Returns: boolean - Returns true if the given child can render, otherwise false.

Source: src/gameobjects/blitter/Blitter.js#L250
Since: 3.0.0


clear

<instance> clear()

Description:

Removes all Bobs from the children List and clears the dirty flag.

Source: src/gameobjects/blitter/Blitter.js#L285
Since: 3.0.0


create

<instance> create(x, y, [frame], [visible], [index])

Description:

Creates a new Bob in this Blitter.

The Bob is created at the given coordinates, relative to the Blitter and uses the given frame.

A Bob can use any frame belonging to the texture bound to the Blitter.

Parameters:

nametypeoptionaldefaultdescription
xnumberNoThe x position of the Bob. Bob coordinate are relative to the position of the Blitter object.
ynumberNoThe y position of the Bob. Bob coordinate are relative to the position of the Blitter object.
framestring | numberPhaser.Textures.FrameYes
visiblebooleanYestrueShould the created Bob render or not?
indexnumberYesThe position in the Blitters Display List to add the new Bob at. Defaults to the top of the list.

Returns: Phaser.GameObjects.Bob - The newly created Bob object.

Source: src/gameobjects/blitter/Blitter.js#L142
Since: 3.0.0


createFromCallback

<instance> createFromCallback(callback, quantity, [frame], [visible])

Description:

Creates multiple Bob objects within this Blitter and then passes each of them to the specified callback.

Parameters:

nametypeoptionaldefaultdescription
callbackCreateCallbackNoThe callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob.
quantitynumberNoThe quantity of Bob objects to create.
framestring | numberPhaser.Textures.FrameArray.<string>Array.<number>
visiblebooleanYestrueShould the created Bob render or not?

Returns: Array.<Phaser.GameObjects.Bob> - An array of Bob objects that were created.

Source: src/gameobjects/blitter/Blitter.js#L182
Since: 3.0.0


createMultiple

<instance> createMultiple(quantity, [frame], [visible])

Description:

Creates multiple Bobs in one call.

The amount created is controlled by a combination of the quantity argument and the number of frames provided.

If the quantity is set to 10 and you provide 2 frames, then 20 Bobs will be created. 10 with the first

frame and 10 with the second.

Parameters:

nametypeoptionaldefaultdescription
quantitynumberNoThe quantity of Bob objects to create.
framestring | numberPhaser.Textures.FrameArray.<string>Array.<number>
visiblebooleanYestrueShould the created Bob render or not?

Returns: Array.<Phaser.GameObjects.Bob> - An array of Bob objects that were created.

Source: src/gameobjects/blitter/Blitter.js#L209
Since: 3.0.0


getRenderList

<instance> getRenderList()

Description:

Returns an array of Bobs to be rendered.

If the Blitter is dirty then a new list is generated and stored in renderList.

Returns: Array.<Phaser.GameObjects.Bob> - An array of Bob objects that will be rendered this frame.

Source: src/gameobjects/blitter/Blitter.js#L265
Since: 3.0.0


preDestroy

<instance> preDestroy()

Description:

Internal destroy handler, called as part of the destroy process.

Access: protected

Source: src/gameobjects/blitter/Blitter.js#L297
Since: 3.9.0