Sprites must be cleaned before switch scenes with SpriteKit and Swift?

不想你离开。 提交于 2019-12-13 04:43:35

问题


There are two scenes(scene1, scene2) in my game, both of them have some sprites. scene1 will be presented at first with skView. scene2 will be presented with the same skView when the hero is stronger. In case the hero is weak, scene1 will be presented again. (Here is the question point.) In my case the sprites which were added to the scene1, are added to the scene1 again(I mean they are doubled).

I did another test, where i presented the scene1 just twice one after the other. I got the same issue.

Why is this happened? Does it mean, that I should remove all the sprites on scene1, before I switch to scene2, and add all sprites again when I switch back???

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

Thanks in advance.

来源:https://stackoverflow.com/questions/26294128/sprites-must-be-cleaned-before-switch-scenes-with-spritekit-and-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!