WGScene
open class WGScene:SKScene
All your widget game scenes should inherit from this class, instead of SKScene.
-
Called when the active display mode changes.
You should override this method if you need to update your scene when the widget changes it’s display mode.
The default implementation of this method is blank.
- activeDisplayMode: The new active display mode. See NCWidgetDisplayMode for possible values.
- maxSize: A CGSize object that represents the new maximum size this widget can have.
Declaration
Swift
open func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize)
-
Called when the widget’s frame changes.
You should override this method if you need to update your scene when the widget updates it’s frame. This usually happens when the widget is transitioning to a different display mode, or to a new preferred content size.
The default implementation for this method is blank.
frame: A CGRect with the new frame size of the widget.
Declaration
Swift
open func didUpdateWidgetFrame(to frame: CGRect)
-
Allows your game scene to change the widget’s expandability or maximum height.
Example of how to change the maximum height of your widget:
widgetDelegate.maxHeight = 200
Declaration
Swift
open var widgetDelegate: WGDelegate?
-
Creates your scene object.
- size: The size of the scene in points.
- controller: The WGDelegate compliant view controller that is creating the scene.
Declaration
Swift
public init(size: CGSize, controller: WGDelegate)
Return Value
A newly initialized WGScene object.
-
Returns an object initialized from data in a given unarchiver.
You typically return self from init(coder:). If you have an advanced need that requires substituting a different object after decoding, you can do so in awakeAfter(using:).
Declaration
Swift
public required init?(coder aDecoder: NSCoder)
Parameters
decoder
An unarchiver object.
Return Value
self, initialized using the data in decoder.