squish
Permet à un objet d'infliger des dégats aux personnages sur lesquels il tombe
require
alive()triggers on self
"stomped"triggers on others
"stomp"parameters
| Parameter | Default Value | Type | Description |
|---|---|---|---|
tag | string | "stomp" | |
groundedDelay | number | 0.0000001 |
example
squish({ tag: "stomp", groundedDelay: 0.0000001}),function squish(p) { const param = { tag: "stomp", groundedDelay: 0.0000001, ...p, }; return { id: "squish", require: ["alive"], add() { let savedTimeTop = time() let savedTimeBot = time() this.onCollideUpdate("body", (obj, col) => { if (this.isAlive) { if (col.isTop()) savedTimeTop = time() if (col.isBottom()) savedTimeBot = time() const top = time() - savedTimeTop < param.groundedDelay const bot = time() - savedTimeBot < param.groundedDelay if (obj.is(param.tag) && top && bot && !col.isLeft() && !col.isRight()) { this.trigger("hit", this.hp()) this.trigger("stomped") obj.trigger("stomp") } } }) }, }}