I have a sprite animation in a class that will get called over and over in different places like so:
sprite=config.gui_t.ball_match_decoration_sprite
sprite:setSequence(‘once’)
sprite:play()
sprite:addEventListener( “sprite”, listener )
And then I destroy it when it is finished like so:
function listener(event)
if (event.phase==“ended”)then
sprite:removeSelf( )
sprite=nil
end
end
My problem is if a sprite gets called to quickly before the previous one has destroyed itself, than that previous one will not remove itself and that image is still on the screen. Can someone please explain a way that I can have all sprites that are called destroy themselves when finished?