Constructor
new PipeGroup(scene, x, y, offset, velocityX)
Setting up default values for the pipe group
Parameters:
| Name | Type | Description |
|---|---|---|
scene |
the scene object from the current scene | |
x |
the x position for the pipes | |
y |
the y position that the pipes will center from | |
offset |
the distance between the top pipe and the bottom pipe | |
velocityX |
the speed at which the pipes will move using Phaser's arcade physics |
- Source:
Methods
create()
This method will carry out the creation and setup for each of the pipe and the checkpoint game objects
- Source:
destroy()
In case the pipes need to be destroyed for any reason, this method will destroy
and remove every game-object in the current PipeGroup object
- Source:
getPosition() → {Object}
Gets and returns the current x and y position of where the current pipe group is located
- Source:
Returns:
- Type
- Object
getWidth() → {number}
Gets and returns the current width of the PipeGroup
- Source:
Returns:
- Type
- number
handleCheckpointOverlap()
This will be called whenever the bird overlaps the checkpoint and will fire
a checkpoint event for points to be added.
- Source:
reset()
This method handles resetting this current object back to its original values or, whatever values it has currently setup
- Source:
setOffset(offset)
This will set the current offset of the pipe and update the pipes positions
accordingly
Parameters:
| Name | Type | Description |
|---|---|---|
offset |
the offset to animate to |
- Source:
setPipeColor(color)
This method will set the current pipe's textures using the given color parameter
Parameters:
| Name | Type | Description |
|---|---|---|
color |
the string variable describing the color of the textured pipe that all the pipes in this object will update to. |
- Source:
setPosition(x, y)
This method will set the class position variable's x and y to the given x and y values. Then
it will update the pipes positions using those new values accordingly
Parameters:
| Name | Type | Description |
|---|---|---|
x |
x value to position to | |
y |
y value to position to |
- Source:
setVelocityX(x)
This method will set the class variable velocityX to the given x variable and
will update the physics game-objects in this class accordingly
Parameters:
| Name | Type | Description |
|---|---|---|
x |
the value to set velocityX with |
- Source:
setupTween(chancePicks) → {Object}
This method will pick a random color out of the chancePicks array with weighted randomization.
The start of the array will be chosen more often then the end.
Parameters:
| Name | Type | Description |
|---|---|---|
chancePicks |
an array of pipe-colors that the method will pick from with the most common color that will be picked in the start of the array and the least common in the back |
- Source:
Returns:
- Type
- Object
startVerticalMovement()
If there is no current vertical animation on this object, it will pick a random pipe texture to start with and based on that,
will animate the pipe with the returned durations. However, if there is already an animation, it will see what color it has currently,
and will pick a new color out of the ones that are left. This way adds more complexity to the game as time goes on. By having three different
colors, this object has 3 different difficulties.
- Source:
stopTween()
If there is an animation object on this game-object, this
method will terminate the current animation and will set the
reference to the variable equal to null
- Source:
updatePosition()
This method will reposition each pipe and checkpoint to the newly set position class variable while also
the given offset class variable.
- Source:
updateVelocityX()
This method will set the physics velocityX to the class velocityX value
- Source: