Constructor
new ShieldBlock(game, shieldGrid, gridX, gridY)
Create a single shield block
Parameters:
Name | Type | Description |
---|---|---|
game |
SpaceInvaders | The current game instance |
shieldGrid |
ShieldGrid | The whole shield grid instance (factory) |
gridX |
number | The shield grid X position |
gridY |
number | The shield grid Y position |
Properties:
Name | Type | Description |
---|---|---|
gridX |
number | The position of this block in the main shield grid |
gridY |
number | The position of this block in the main shield grid |
shieldGrid |
ShieldGrid | The main shield grid this block is a part of |
- Source:
Extends
Methods
destroy() → {boolean}
Destroy this shield block, hide the DOM Element and remove
instance from the shieldBlocks array.
- Source:
- To Do:
-
- Delete the DOM element, pass this control to the shieldBlock factory?
Returns:
- Type
- boolean
destroyDomElement() → {boolean}
Remove this DOM element from the HTML document.
- Inherited From:
- Source:
Returns:
- Type
- boolean
detectCollisionWith(sprite) → {boolean}
Detect collision between two sprites. Checks for any gaps between
the sprites.
Parameters:
Name | Type | Description |
---|---|---|
sprite |
Sprite | The sprite we are checking for a collision with. |
- Inherited From:
- Source:
Returns:
True if collision
- Type
- boolean
draw()
Update the DOM Element style properties to move the sprite
- Inherited From:
- Source:
inMe(x, y) → {boolean}
Is the x, y game world point inside this sprite.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The X position. |
y |
number | The Y position. |
- Inherited From:
- Source:
Returns:
True if inside
- Type
- boolean
makeDomElement(css) → {boolean}
Make the DOM element for this sprite inside the Game element.
Parameters:
Name | Type | Description |
---|---|---|
css |
string | CSS style to apply to the element. |
- Inherited From:
- Source:
Returns:
- Type
- boolean
makeDomElementInside(parent, css) → {boolean}
Make the DOM element for this sprite inside the supplied element
and assign it the supplied css class.
Parameters:
Name | Type | Description |
---|---|---|
parent |
Sprite | The parent sprite or object with a DOM element. |
css |
string | CSS style to apply to the element. |
- Inherited From:
- Source:
Returns:
- Type
- boolean
move() → {boolean}
Move the sprite, overide this method in classes extending the Sprite class.
Called on every game loop.
- Inherited From:
- Source:
Returns:
- Type
- boolean
receiveDamage() → {boolean}
Receive damage and destroy this shield block
- Overrides:
- Source:
Returns:
True if this killed it, false if just wounded
- Type
- boolean
receiveHealth(health) → {boolean}
Receive health
Parameters:
Name | Type | Description |
---|---|---|
health |
number | The amount of health / hit points received. |
- Inherited From:
- Source:
Returns:
- Type
- boolean
update() → {boolean}
Update loop, call the move() and draw() methods.
- Inherited From:
- Source:
Returns:
- Type
- boolean