API Docs for:
Show:

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

()

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 Object

    The force generator object.

  • entity Entity

    The 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 Object

    The force generator object used when creating the entry.

  • entity Entity

    The entity used when creating the entry.

removeEntity

(
  • entity
)

Removes all entries from the registry that have the specified entity.

Parameters:

removeForceGenerator

(
  • forceGenerator
)

Removes all entries from the registry that have the specified force generator.

Parameters:

  • forceGenerator Object

    The force generator object.

update

(
  • deltaTime
)

Parameters:

  • deltaTime Number

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