Merge all SKSpriteNode children into a single SKSpriteNode

我们两清 提交于 2020-01-04 08:06:59

问题


How can I take an SKSpriteNode and all its child SKSpriteNodes and merge them down into a single flattened SKSpriteNode with no children?

Thanks.


回答1:


Create a texture of the node and create a new sprite from that texture:

SKTexture* tex = [self.scene.view textureFromNode:parentSprite];
SKSpriteNode* newSprite = [SKSpriteNode spriteNodeWithTexture:tex];

PS: be sure not to run this in init otherwise self.view will be nil.



来源:https://stackoverflow.com/questions/26075496/merge-all-skspritenode-children-into-a-single-skspritenode

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