Class: Bob

Phaser.GameObjects. Bob

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.


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
Source: src/gameobjects/blitter/Bob.js (Line 10)

Members


alpha :number

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

A Bob with alpha 0 will skip rendering.

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/blitter/Bob.js (Line 398)

data :object

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

Type:
  • object
Since: 3.0.0
Default Value:
  • {}
Source: src/gameobjects/blitter/Bob.js (Line 81)

flipX :boolean

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
Source: src/gameobjects/blitter/Bob.js (Line 122)

flipY :boolean

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
Source: src/gameobjects/blitter/Bob.js (Line 133)

<protected> frame :Phaser.Textures.Frame

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

Type:
Since: 3.0.0
Source: src/gameobjects/blitter/Bob.js (Line 70)

parent :Phaser.GameObjects.Blitter

The Blitter object that this Bob belongs to.

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

tint :number

The tint value of this Bob.

Type:
  • number
Since: 3.20.0
Default Value:
  • 0xffffff
Source: src/gameobjects/blitter/Bob.js (Line 91)

visible :boolean

The visible state of the Bob.

An invisible Bob will skip rendering.

Type:
  • boolean
Since: 3.0.0
Source: src/gameobjects/blitter/Bob.js (Line 374)

x :number

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

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/blitter/Bob.js (Line 52)

y :number

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

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/blitter/Bob.js (Line 61)

Methods


destroy()

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

Since: 3.0.0
Source: src/gameobjects/blitter/Bob.js (Line 356)

reset(x, y [, frame])

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

Since: 3.0.0
Source: src/gameobjects/blitter/Bob.js (Line 191)
Returns:

This Bob Game Object.

Type
Phaser.GameObjects.Bob

resetFlip()

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

Since: 3.0.0
Source: src/gameobjects/blitter/Bob.js (Line 175)
Returns:

This Bob Game Object.

Type
Phaser.GameObjects.Bob

setAlpha(value)

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.

Since: 3.0.0
Source: src/gameobjects/blitter/Bob.js (Line 319)
Returns:

This Bob Game Object.

Type
Phaser.GameObjects.Bob

setFlip(x, y)

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.

Since: 3.0.0
Source: src/gameobjects/blitter/Bob.js (Line 281)
Returns:

This Bob Game Object.

Type
Phaser.GameObjects.Bob

setFlipX(value)

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.

Since: 3.0.0
Source: src/gameobjects/blitter/Bob.js (Line 247)
Returns:

This Bob Game Object.

Type
Phaser.GameObjects.Bob

setFlipY(value)

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.

Since: 3.0.0
Source: src/gameobjects/blitter/Bob.js (Line 264)
Returns:

This Bob Game Object.

Type
Phaser.GameObjects.Bob

setFrame( [frame])

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 Argument Description
frame string | number | Phaser.Textures.Frame <optional>

The frame to be used during rendering.

Since: 3.0.0
Source: src/gameobjects/blitter/Bob.js (Line 145)
Returns:

This Bob Game Object.

Type
Phaser.GameObjects.Bob

setPosition(x, y)

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.

Since: 3.20.0
Source: src/gameobjects/blitter/Bob.js (Line 228)
Returns:

This Bob Game Object.

Type
Phaser.GameObjects.Bob

setTint(value)

Sets the tint of this Bob.

Parameters:
Name Type Description
value number

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

Since: 3.20.0
Source: src/gameobjects/blitter/Bob.js (Line 339)
Returns:

This Bob Game Object.

Type
Phaser.GameObjects.Bob

setVisible(value)

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.

Since: 3.0.0
Source: src/gameobjects/blitter/Bob.js (Line 300)
Returns:

This Bob Game Object.

Type
Phaser.GameObjects.Bob