Foundation.Keys4WaySpriteDirector
This director binds sprite left, right, up, and down movement to a set of specified keys (WASD by default).
Example
// Assuming a sprite stored as `sprite`, and a default game prefab
sprite.directors.push(new Foundation.Keys4WaySpriteDirector(
game['time'], // Game's GameTimeTracker object reference
game['keys'], // Game's KeysController object reference
null, // Use default WASD movement
new Vector2(100, 200) // Speed: move 100 units per second on x, 200 on y
));
Implementation Details
Reference paths
'/foundation/_digest.ts''/foundation/core/directors/_digest.ts''/foundation/core/directors/Keys4WaySpriteController.ts'
Extends
This type does not extend a base type.
Implements
This type implements the following interfaces:
Public Properties
speed: Vector2
- The number of units your sprite can travel on x and y per second.
Constructors
public constructor(time: GameTimeTracker, keyController: KeyController, moveKeys: Keys4Way = {up: KeyCodes.w, down: KeyCodes.s, left: KeyCodes.a, right: KeyCodes.d}, speed: Vector2 = new Vector2(100, 100))
time- Your game's time tracker object.keyController- Your game's key controller object.moveKeys- Keys to use for movement. Defaults :{up: KeyCodes.w, down: KeyCodes.s, left: KeyCodes.a, right: KeyCodes.d}speed- The number of units your sprite can travel on x and y per second. Defaults to(100, 100)