Skip to content

Show and hide a sprite

Bind keys to show and hide to let the player toggle a spriteโ€™s visibility.

whenKeyPressed("space", () => {
hide();
});
whenKeyPressed("up arrow", () => {
show();
});

Pressing Space makes the sprite invisible; pressing Up brings it back.

  • whenKeyPressed โ€” run code when a key is pressed
  • show โ€” make this sprite visible
  • hide โ€” hide this sprite
All recipes