Merge all SKSpriteNode children into a single SKSp

2019-07-20 20:19发布

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条回答
够拽才男人
2楼-- · 2019-07-20 20:28

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.

查看更多
登录 后发表回答