Function

stay

(scenesToStay?: string[]): StayComp

Don't get destroyed on scene switch. Only works in objects attached to root.

param scenesToStay- The scenes to stay in. By default it stays in all scenes.

player.onCollide("bomb", () => {
    // spawn an explosion and switch scene, but don't destroy the explosion game obj on scene switch
    add([
        sprite("explosion", { anim: "burst", }),
        stay(),
        lifespan(1),
    ])
    go("lose", score)
})

returns The stay comp.

since v2000.0

group Components

kaplay logo

Layer

Miscalenous