Author Topic: Removing a sprite created through sol.sprite.create ?  (Read 481 times)


  • Hero Member
  • *****
  • Posts: 551
    • View Profile
Removing a sprite created through sol.sprite.create ?
« on: October 08, 2017, 05:18:54 pm »

I'm having troubble with cutscenes and sprites management.
I am currently making sage cutscenes with as inspiration ALTTP, but, after a while, the crystal around the sage needs to be removed

The sprite creation is a bit different because the cutscene starts immediately after the boss died, a surface fades to accomplish the black background, a menu handles the whole cutscene (mostly to overwrite and avoid pausing / moving, doing actions during cutscene)

Sprites are created in this order

black surface
Link sprite
Sage sprite
Crystal sprite

All created by sol.surface / sprite.create

But, calling

Code: [Select]
this happen

Code: [Select]
Error: In timer callback: [string "maps/cutscene_data/SageScene_0.lua"]:95: attempt to call method 'remove' (a nil value)
I can't use map entities because the menu is started above everything on the map, entities are not visible during the cutscene because of the background surface
Which confuse me a bit, we can't remove a sprite ?
« Last Edit: October 08, 2017, 05:33:36 pm by MetalZelda »


  • Administrator
  • Hero Member
  • *****
  • Posts: 1140
    • View Profile
Re: Removing a sprite created through sol.sprite.create ?
« Reply #1 on: October 08, 2017, 05:26:46 pm »
entity:remove() removes the entity from the map. That's why sprites have no method remove(): they are not on the map.

If you want to stop displaying a sprite, simply stop calling sprite:draw() in your draw event. A good practice is also to assign nil to the sprite so that its memory gets freed.