在NSScrollView中使用SKView时出现可怕的闪烁

时间:2015-03-20 12:21:29

标签: macos cocoa swift sprite-kit skshapenode

不幸的是,在SKView中使用NSScrollView似乎完全无法使用。

Project available on github.

有没有人有任何聪明的解决方法,或者我做了一些非常愚蠢的事情?

  • 滚动时可怕的闪烁
  • 调整窗口大小时可怕的闪烁
  • 形状是一个圆圈,然而,纵横比会变得混乱。

我在MacBook Pro上运行此功能(Retina,2012年中),OS X 10.10.2;可能是特定于设备的。

Terrible flicker

这是代码,一切都在AppDelegate中设置,

class AppDelegate: NSObject, NSApplicationDelegate {

    @IBOutlet weak var window: NSWindow!

    @IBOutlet weak var spriteKitView: SKView!

    @IBOutlet weak var scrollView: NSScrollView!

    var scene : SKScene?
    var rootNode : SKNode?
    var shape : SKShapeNode?
    var sprite : SKSpriteNode?

    func applicationDidFinishLaunching(aNotification: NSNotification) {
        // Insert code here to initialize your application

        let side = 500.0
        scene = SKScene(size: CGSize(width: side, height:side))
        scene?.backgroundColor = NSColor.whiteColor()
        spriteKitView.presentScene(scene)
        spriteKitView.setFrameSize(CGSize(width: side, height: side))
        scrollView.scrollPoint(CGPoint(x: CGFloat(side/2), y: CGFloat(side/2)))

        // Add root node
        rootNode = SKNode()
        scene!.addChild(rootNode!)

        // Add shape to root node
        shape = SKShapeNode(circleOfRadius: CGFloat(side/10))
        shape!.fillColor = NSColor.redColor()
        shape!.lineWidth = 1.0
        shape!.position = CGPoint(x: CGFloat(side/2), y: CGFloat(side/2))
        rootNode!.addChild(shape!)

        //
        sprite = SKSpriteNode(imageNamed: "image")
        rootNode!.addChild(sprite!)

    }

    func applicationWillTerminate(aNotification: NSNotification) {
        // Insert code here to tear down your application
    }
}

0 个答案:

没有答案