vanishing
require
opacity()sight()parameters
| Parameter | Default Value | Type | Description |
|---|---|---|---|
tag | string | 'player' | |
delay | number | 0.2 | |
on | boolean | true |
example
vanishing({ tag: 'player', delay: 0.2, on: true}),function vanishing(p) { const param = { tag: 'player', delay: 0.2, on: true, ...p, }; return { require: ['opacity', 'sight'], id: 'vanishing', vanishingOn: param.on, add() { this.opacity = 0; }, update() { if (this.vanishingOn) { const opcaity = !this.isOffScreen() && this.currentTarget ? 1 : 0; tween(this.opacity, opcaity, param.delay, (v) => (this.opacity = v)); } }, };}