How to reset Wall Sprites?

How can I reset Wall Sprites for another level?

I use gfx.sprite.addWallSprites(tilemap, {1,2}) to set Wall Sprites for level x. When I do the same for level y, the wall sprites for level x do not get removed. How can I achieve this?

The whole function looks like this

function createMap()
  local currentMap = rld(levels[level].map)
  tilemap:setTiles(currentMap, columnCount)
  sprite:setBounds(0,0,sprite:getSize())
  sprite:setTilemap(tilemap)
  sprite:setZIndex(0)
  -- TODO: Figure out resetting the wall sprites
  gfx.sprite.addWallSprites(tilemap, {1,2})
  map = sprite
  levelTiles = tilemap
end

I can't find a function to remove wall sprites in the docs.

I use macOS as operating system. Here are screenshots of the first three levels:

Level 1

Level 2

Level3

Cheers,
Mario

Try

myWalls = gfx.sprite.addWallSprites(tilemap, {1,2})

Then you can go through that array and remove all the sprites. Finally init your new level.

In the docs: https://sdk.play.date/inside-playdate/#f-graphics.sprite.addWallSprites

addWallSprites: Returns an array-style table of the newly created sprites.

1 Like

Thank you @matt
I’ll try that!

That worked, thank you for your help!

Cheers,
Mario

1 Like