healing
Permet à un objet de donner des points de vie à un joueur lorsqu'il entre collision avec lui
triggers on self
"heal""disapear""maxed out"triggers on others
"heal"parameters
| Parameter | Default Value | Type | Description |
|---|---|---|---|
duration | number | 0.4 | |
amplitude | number | 10 | |
speed | number | 2 |
example
healing({ duration: 0.4, amplitude: 10, speed: 2}),function healing(p) { const param = { duration: 0.4, amplitude: 10, speed: 2, ...p } return { id: "healing", add() { this.onCollide("player", (obj) => this.healCollide(obj)) this.on("disapear", () => { if (this.is("respawn")) this.hideFromScene() else destroy(this) }) }, healCollide(obj) { if (!this.is("respawn") || !this.beenHidden) { if (obj.maxHP() == null || obj.hp() < obj.maxHP()) this.getHealth(obj) else this.maxedOutHealth() } }, getHealth(obj) { obj.heal(1) obj.trigger("heal") this.trigger("heal") this.trigger("disapear") }, maxedOutHealth() { tween(0, Math.PI * 2, param.duration, (v) => { this.angle = Math.sin(v * param.speed) * param.amplitude, easings.easeOutSine }) this.trigger("maxed out") } }}