play icon indicating copy to clipboard operation
play copied to clipboard

How to clear all sprites on the screen or chosen sprites.

Open tanjavaner opened this issue 3 years ago • 4 comments

Is there a way to completely delete sprites with any function or smth ?

tanjavaner avatar Aug 09 '22 11:08 tanjavaner

@tanjavaner Have you tried using sprite.remove()?

ducaale avatar Aug 09 '22 11:08 ducaale

I tried remove() but I want to delete it completely .

For example lets say I have 7 sprites on the screen.

sp1 , sp2 , sp3 , sp4 , sp5 , sp6 , sp7

When I want to make a simple platformer game the first 7 sprites should be removed from technically and graphically so I can add other stage's sprites . I can only hide it can not be completely removed from the screen and memory.

tanjavaner avatar Aug 09 '22 11:08 tanjavaner

Calling remove() on a sprite will unregister and remove it from the screen. But if for some reason you need to remove it from memory as well, you can unset the variable that holds the sprite object so the garbage collector can do its thing.

ducaale avatar Aug 11 '22 20:08 ducaale

Thank you so much

tanjavaner avatar Aug 18 '22 00:08 tanjavaner