Should sprites be cleared before switching scenes using SpriteKit and Swift?

There are two scenes in my game (scene1, scene2), both of them have sprites. scene1 will be presented first with skView. scene2 will be represented by the same skView when the hero is stronger. If the hero is weak, the scene will be presented again. (Here's the question.) In my case, the sprites that were added to scene1 are added to scene1 again (I mean they double).

I did another test where I presented scene1 twice twice in succession. I have the same problem.

Why did this happen? Does this mean that I have to delete all the sprites on scene1 before switching to scene2 and add all the sprites again when I go back.

PS: the question is related to How to properly switch SKScenes to SpriteKit using Swift? .

Thanks in advance.

0
source share

All Articles