Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Make Opacity required component for Lifespan. #826

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/kaboom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4653,10 +4653,11 @@ export default (gopt: KaboomOpt = {}): KaboomCtx => {
const fade = opt.fade ?? 0
return {
id: "lifespan",
require: [ "opacity" ],
async add(this: GameObj<OpacityComp>) {
await wait(time)
// TODO: this secretively requires opacity comp, make opacity on every game obj?
if (fade > 0 && this.opacity) {
this.opacity = this.opacity ?? 1
if (fade > 0) {
await tween(this.opacity, 0, fade, (a) => this.opacity = a, easings.linear)
}
this.destroy()
Expand Down