2014-09-02 5 views
0

SKScene이 있는데 특정 레이어의 스냅 샷을 원합니다. SKView가있는 흰색 UIView에 표시되는 레이어 일 수 있습니다. 하지만 결국이 레이어의 상태에서만 스냅을 사용하고 싶습니다. 미리 감사드립니다. 나를 위해 일한 무엇SKNode의 스냅 샷을 생성 할 수 있습니까?

+2

https://developer.apple.com/library/ios/documentation/SpriteKit/Reference/SKView/Reference/Reference.html#//apple_ref/occ/instm/SKView/textureFromNode : – LearnCocos2D

+0

@ LearnCocos2D 감사합니다. 문서에 대한 답변. .textureFromNode()는 트릭을 수행 할 수있는 메소드입니다. – vyudi

답변

-1

:

var tempView = UIView(frame: CGRectMake(0, 0, 500, 500)) 
    var tempSKView = SKView(frame: tempView.frame) 
    var tempScene = SKScene(size: tempSKView.bounds.size) 

    var lineTexture = SKTexture() 
    lineTexture = skView.textureFromNode(scene.lineLayer) 

    var lineLayerCopy = SKSpriteNode(texture: lineTexture) 
    lineLayerCopy.anchorPoint = CGPoint(x: 0.0, y: 0.0) 
    lineLayerCopy.size = CGSizeMake(500, 500) 
    tempScene.addChild(lineLayerCopy) 
    tempScene.backgroundColor = UIColor.whiteColor() 
    tempSKView.presentScene(tempScene) 
    tempView.addSubview(tempSKView) 
    self.view.addSubview(tempView) 

참고 : anchorPoint이 필수적이다. 장면이 중앙에 배치되도록하여 완벽한 이미지를 얻을 수 있습니다.

관련 문제