有谁知道如何"快照"一个完整的SKView
或SKScene
一个NSImage
?
我们已经能够使用textureFromNode
API SKTexture
从节点及其所有子节点创建.但到目前为止,我们无法找到一种方法将图像数据提取为一个NSImage
.我们正在构建一个混合Cocoa
/ SpriteKit
应用程序,我们需要提取场景的小缩略图.
再次,这似乎可以在iOS(获得a UIImage
)使用drawViewHierarchyInRect
:
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, scale); [self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
但如何做到这一点上Cocoa
有NSImage
?救命.