Skip to content

Commit 59c1be2

Browse files
authored
fix: make lifespan require opacity
2 parents 5e16da1 + 91c45b8 commit 59c1be2

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

src/kaboom.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4762,17 +4762,12 @@ export default (gopt: KaboomOpt = {}): KaboomCtx => {
47624762
const fade = opt.fade ?? 0;
47634763
return {
47644764
id: "lifespan",
4765+
require: [ "opacity" ],
47654766
async add(this: GameObj<OpacityComp>) {
47664767
await wait(time);
4767-
// TODO: this secretively requires opacity comp, make opacity on every game obj?
4768-
if (fade > 0 && this.opacity) {
4769-
await tween(
4770-
this.opacity,
4771-
0,
4772-
fade,
4773-
(a) => this.opacity = a,
4774-
easings.linear,
4775-
);
4768+
this.opacity = this.opacity ?? 1
4769+
if (fade > 0) {
4770+
await tween(this.opacity, 0, fade, (a) => this.opacity = a, easings.linear);
47764771
}
47774772
this.destroy();
47784773
},

0 commit comments

Comments
 (0)