ForceGeneratorRegistry Class
This registry provides a universal interface for dealing with force generators and entities those generators affect. The registry requires that the force generators provide a function named "applyForce". This function should accept an entity and, if required, a second parameter, usually the time delta (see the update method). For examples of the implementation see the provided force generators.
Constructor
ForceGeneratorRegistry
()
Item Index
Methods
Methods
add
-
forceGenerator
-
entity
Adds an entry into the registry. From now on, each time the registry is updated, the force generator will be used to apply a force to the entity.
Parameters:
-
forceGenerator
ObjectThe force generator object.
-
entity
EntityThe entity this generator should apply force to.
clear
()
Removes all entries from the registry.
remove
-
forceGenerator
-
entity
Removes a single entry from the registry.
Parameters:
-
forceGenerator
ObjectThe force generator object used when creating the entry.
-
entity
EntityThe entity used when creating the entry.
removeEntity
-
entity
Removes all entries from the registry that have the specified entity.
Parameters:
-
entity
Entity
removeForceGenerator
-
forceGenerator
Removes all entries from the registry that have the specified force generator.
Parameters:
-
forceGenerator
ObjectThe force generator object.
update
-
deltaTime
Parameters:
-
deltaTime
NumberThis is the second paramterer sent to each applyForce call. It's meant to be used for sending the frame time, since some force generators may require it, but since this is JavaScript, it can be anything.