A question about layers in Kaboom


I made a game called Protect Your Computer, and the objective is to try to destroy the virus (bean) and click extra popup windows.

I tried to make the bean show on top of the popups, but the popups are still at the top, even though I used layers. Are there any problems with the code I wrote, or problems with Kaboom?

Repl link: https://replit.com/@OnlyAHuman/Protect-Your-Computer?v=1


I wrote the layers this way:

layers([
  "bg",
  "play",
  "popup",
  "scoreboard",
  "viruses"
], "play");


this.body = add([                // this is the virus object
      sprite(this.sprite),
      pos(Math.random() * width(), Math.random() * height()),
      area(),
      layer("viruses")
    ]);

let popUp = add([
      sprite("popup"),
      ...
      layer("popup")
    ]);
1 Like

Weird, it doesn’t seem to work in Replit on the cover page, but when I open it in a new tab it works fine…

Thanks for telling me that it doesn’t work on the cover page, and I’ve fixed the problem with the cover page.

What I’m actually stuck on is that I wanted the bean to be on top of the popup windows and I added the corresponding code, but the popup is still on top.
image

2 Likes