throwBallController
Permet à un objet de lancer une balle lorsqu'un joueur appuie sur shootKey
require
alive()throwBall()parameters
| Parameter | Default Value | Type | Description |
|---|---|---|---|
shootKey | string | "space" | |
reloadDelay | number | 0 |
example
throwBallController({ shootKey: "space", reloadDelay: 0}),function throwBallController(p) { const param = { shootKey: "space", reloadDelay: 0, ...p } return { id: "throwBallController", require: ["alive", "throwBall"], throwSavedTime: 0, add() { onKeyPress(param.shootKey, () => this.throwBallTrigger()) }, throwBallTrigger() { if (this.isAlive && time() - this.throwSavedTime > param.reloadDelay) { this.trigger("throw", this.facing) this.throwSavedTime = time() } }, }}