Class: Factory

Factory(game, maxItems, minDelay, maxDelay)

Abstract factory, extended by BubbleFactory, EnemyFleet, BonusFactory etc - provides basic factory operations. Timed auto creation option, random timer

Constructor

new Factory(game, maxItems, minDelay, maxDelay)

Make the factory instance
Parameters:
Name Type Description
game SpaceInvaders Main game instance
maxItems number Maximum number of items in the store
minDelay number Minimum delay before auto creating
maxDelay number Maximum delay before auto creating
Properties:
Name Type Description
game SpaceInvaders Main game instance
makeCounter number Count of how many instances have been made by this factory
items array Store the items created in here.
maxItems number Maximum number of items in the store
minDelay number Minimum delay before auto creating
maxDelay number Maximum delay before auto creating
countdown number Countdown till the next auto create
Author:
Source:

Methods

canMake() → {boolean}

Check if we can make a new instance based on maxItems
Source:
Returns:
Type
boolean

destroy(item) → {Object}

Destroy an instance created by this factory
Parameters:
Name Type Description
item Object The item / instance to destroy
Source:
Returns:
Returns the instance created
Type
Object

make()

Usuall method called to make a new item in this factory
Source:

makeItem() → {Object}

Make the actual item, called by the make() method
Source:
Returns:
Returns the instance created
Type
Object

reset()

Destroy all items and reset the data
Source:

resetCountdown()

Restart the auto make countdown based on max / min delay
Source:

update()

Main update loop
Source: