Phaser API Documentation

  Version: 
Filter

A Bob Game Object.

A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object.

A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it must be a Frame within the Texture used by the parent Blitter.

Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will have their positions impacted by this change as well.

You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be handled via the Blitter parent.

Constructor:

new Bob(blitter, x, y, frame, visible)

Parameters:

name type description
blitter Phaser.GameObjects.Blitter

The parent Blitter object is responsible for updating this Bob.

x number

The horizontal position of this Game Object in the world, relative to the parent Blitter position.

y number

The vertical position of this Game Object in the world, relative to the parent Blitter position.

frame string | number

The Frame this Bob will render with, as defined in the Texture the parent Blitter is using.

visible boolean

Should the Bob render visible or not to start with?

Since: 3.0.0

Members

<private> _alpha: number
Focus
Focus

Description:

The alpha value of this Bob.

Type:
number
Default: 1
Since: 3.0.0
Focus
Focus
<private> _visible: boolean
Focus
Focus

Description:

The visible state of this Bob.

Type:
boolean
Since: 3.0.0
Focus
Focus
alpha: number
Focus
Focus

Description:

The alpha value of the Bob, between 0 and 1.

A Bob with alpha 0 will skip rendering.

Type:
number
Since: 3.0.0
Focus
Focus
data: object
Focus
Focus

Description:

A blank object which can be used to store data related to this Bob in.

Type:
object
Default: {}
Since: 3.0.0
Focus
Focus
flipX: boolean
Focus
Focus

Description:

The horizontally flipped state of the Bob. A Bob that is flipped horizontally will render inversed on the horizontal axis. Flipping always takes place from the middle of the texture.

Type:
boolean
Since: 3.0.0
Focus
Focus
flipY: boolean
Focus
Focus

Description:

The vertically flipped state of the Bob. A Bob that is flipped vertically will render inversed on the vertical axis (i.e. upside down) Flipping always takes place from the middle of the texture.

Type:
boolean
Since: 3.0.0
Focus
Focus
<protected> frame: Phaser.Textures.Frame
Focus
Focus

Description:

The frame that the Bob uses to render with. To change the frame use the Bob.setFrame method.

Type:
Since: 3.0.0
Focus
Focus
<private, readonly> hasTransformComponent: boolean
Focus
Focus

Description:

Private read-only property used to allow Bobs to have physics bodies.

Type:
boolean
Since: 3.60.0
Focus
Focus

Description:

The Blitter object that this Bob belongs to.

Type:
Since: 3.0.0
Focus
Focus
tint: number
Focus
Focus

Description:

The tint value of this Bob.

Type:
number
Default: 0xffffff
Since: 3.20.0
Focus
Focus
visible: boolean
Focus
Focus

Description:

The visible state of the Bob.

An invisible Bob will skip rendering.

Type:
boolean
Since: 3.0.0
Focus
Focus
x: number
Focus
Focus

Description:

The x position of this Bob, relative to the x position of the Blitter.

Type:
number
Since: 3.0.0
Focus
Focus
y: number
Focus
Focus

Description:

The y position of this Bob, relative to the y position of the Blitter.

Type:
number
Since: 3.0.0
Focus
Focus

Methods

destroy()
Focus
Focus

Description:

Destroys this Bob instance. Removes itself from the Blitter and clears the parent, frame and data properties.

Since: 3.0.0
Focus
Focus
reset(x, y, [frame])
Focus
Focus

Description:

Resets this Bob.

Changes the position to the values given, and optionally changes the frame.

Also resets the flipX and flipY values, sets alpha back to 1 and visible to true.

Parameters:

name type arguments description
x number

The x position of the Bob. Bob coordinate are relative to the position of the Blitter object.

y number

The y position of the Bob. Bob coordinate are relative to the position of the Blitter object.

frame string | number | Phaser.Textures.Frame <optional>

The Frame the Bob will use. It must be part of the Texture the parent Blitter object is using.

Returns:
Description:

This Bob Game Object.

Since: 3.0.0
Focus
Focus
resetFlip()
Focus
Focus

Description:

Resets the horizontal and vertical flipped state of this Bob back to their default un-flipped state.

Returns:
Description:

This Bob Game Object.

Since: 3.0.0
Focus
Focus
setAlpha(value)
Focus
Focus

Description:

Set the Alpha level of this Bob. The alpha controls the opacity of the Game Object as it renders. Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque.

A Bob with alpha 0 will skip rendering.

Parameters:

name type description
value number

The alpha value used for this Bob. Between 0 and 1.

Returns:
Description:

This Bob Game Object.

Since: 3.0.0
Focus
Focus
setFlip(x, y)
Focus
Focus

Description:

Sets the horizontal and vertical flipped state of this Bob.

Parameters:

name type description
x boolean

The horizontal flipped state. false for no flip, or true to be flipped.

y boolean

The horizontal flipped state. false for no flip, or true to be flipped.

Returns:
Description:

This Bob Game Object.

Since: 3.0.0
Focus
Focus
setFlipX(value)
Focus
Focus

Description:

Sets the horizontal flipped state of this Bob.

Parameters:

name type description
value boolean

The flipped state. false for no flip, or true to be flipped.

Returns:
Description:

This Bob Game Object.

Since: 3.0.0
Focus
Focus
setFlipY(value)
Focus
Focus

Description:

Sets the vertical flipped state of this Bob.

Parameters:

name type description
value boolean

The flipped state. false for no flip, or true to be flipped.

Returns:
Description:

This Bob Game Object.

Since: 3.0.0
Focus
Focus
setFrame([frame])
Focus
Focus

Description:

Changes the Texture Frame being used by this Bob. The frame must be part of the Texture the parent Blitter is using. If no value is given it will use the default frame of the Blitter parent.

Parameters:

name type arguments description
frame string | number | Phaser.Textures.Frame <optional>

The frame to be used during rendering.

Returns:
Description:

This Bob Game Object.

Since: 3.0.0
Focus
Focus
setPosition(x, y)
Focus
Focus

Description:

Changes the position of this Bob to the values given.

Parameters:

name type description
x number

The x position of the Bob. Bob coordinate are relative to the position of the Blitter object.

y number

The y position of the Bob. Bob coordinate are relative to the position of the Blitter object.

Returns:
Description:

This Bob Game Object.

Since: 3.20.0
Focus
Focus
setTint(value)
Focus
Focus

Description:

Sets the tint of this Bob.

Parameters:

name type description
value number

The tint value used for this Bob. Between 0 and 0xffffff.

Returns:
Description:

This Bob Game Object.

Since: 3.20.0
Focus
Focus
setVisible(value)
Focus
Focus

Description:

Sets the visibility of this Bob.

An invisible Bob will skip rendering.

Parameters:

name type description
value boolean

The visible state of the Game Object.

Returns:
Description:

This Bob Game Object.

Since: 3.0.0
Focus
Focus