I am creating a program and I would like the UI to change based on the size of the window. I'm looking for some method that is called when the window has been resized. I went to the documentation for windowDidResize, but I cannot get it to work when the window is resized.
import SpriteKit
import AppKit
class GameScene: SKScene , SKPhysicsContactDelegate ,NSWindowDelegate{
**** bunch of code ****
func windowDidResize (notification: NSNotification) {
HUDComp.updatePosition(size)
println("Screen has been resized")
}
}
Any info would be greatly appreciated.
If you inherit NSWindowDelegate, the only thing you should do is add observer onto NSNotificationCenter. Code is here.
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("windowDidResize:"), name: NSWindowDidResizeNotification, object: nil)