SKTiledScene
open class SKTiledScene : SKScene, SKPhysicsContactDelegate, SKTiledSceneDelegate, SKTilemapDelegate, SKTilesetDataSource
extension SKTiledScene: SKTiledSceneCameraDelegate
Overview
Custom scene type for managing SKTilemap
nodes.
Conforms to the SKTiledSceneDelegate
, SKTilemapDelegate
& SKTilesetDataSource
protocols.
Properties
Property | Description |
---|---|
worldNode | Root container node. |
tilemap | Tile map object. |
cameraNode | Custom scene camera. |
Instance Methods
Method | Description |
---|---|
sceneDoubleTapped | Called when the scene receives a double-tap event (iOS only). |
cameraPositionChanged | Called when the camera positon changes. |
cameraZoomChanged | Called when the camera zoom changes. |
cameraBoundsChanged | Called when the camera bounds updated. |
sceneDoubleClicked | Called when the scene is double-clicked (macOS only). |
mousePositionChanged | Called when the mouse moves in the scene (macOS only). |
-
World container node.
Declaration
Swift
open var worldNode: SKNode!
-
▶︎tilemap
Tile map node.
Declaration
Swift
open var tilemap: SKTilemap!
-
Custom scene camera.
Declaration
Swift
open var cameraNode: SKTiledSceneCamera!
-
Logging verbosity level.
Declaration
Swift
open var loggingLevel: LoggingLevel
-
▶︎graphs
Reference to navigation graphs.
Declaration
Swift
open var graphs: [String : GKGridGraph<GKGridGraphNode>]
-
Receive notifications from camera.
Declaration
Swift
open var receiveCameraUpdates: Bool
-
▶︎speed
Set the tilemap speed.
Declaration
Swift
override open var speed: CGFloat { get set }
-
Initialize without a tiled map.
Declaration
Swift
required override public init(size: CGSize)
Parameters
size
CGSize
scene size.Return Value
SKTiledScene
scene. -
Default initializer.
Declaration
Swift
required public init?(coder aDecoder: NSCoder)
Parameters
aDecoder
decoder instance.
-
Called when the parent view size changes.
Declaration
Swift
override open func didChangeSize(_ oldSize: CGSize)
Parameters
oldSize
previous size.
-
Called when the parent view is displayed.
Declaration
Swift
override open func didMove(to view: SKView)
Parameters
view
parent view.
-
Load and setup a named TMX file, with optional tilesets.
Declaration
Swift
open func setup(url: URL, withTilesets: [SKTileset] = [], ignoreProperties: Bool = false, loggingLevel: LoggingLevel = TiledGlobals.default.loggingLevel, _ completion: ((_ tilemap: SKTilemap) -> Void)? = nil)
Parameters
url
URL
Tiled file url.withTilesets
[SKTileset]
pre-loaded tilesets.ignoreProperties
Bool
don’t parse custom properties.loggingLevel
LoggingLevel
logging verbosity.completion
((_ SKTilemap) -> Void)?
optional completion handler. -
Load and setup a named TMX file, with optional tilesets. Allows for an optional completion handler.
Declaration
Swift
open func setup(tmxFile: String, inDirectory: String? = nil, withTilesets tilesets: [SKTileset] = [], ignoreProperties: Bool = false, loggingLevel: LoggingLevel = TiledGlobals.default.loggingLevel, _ completion: ((_ tilemap: SKTilemap) -> Void)? = nil)
Parameters
tmxFile
String
TMX file name.inDirectory
String?
search path for assets.withTilesets
[SKTileset]
optional pre-loaded tilesets.ignoreProperties
Bool
don’t parse custom properties.loggingLevel
LoggingLevel
logging verbosity.completion
((_ SKTilemap) -> Void)?
optional completion handler.
-
Called before each frame is rendered.
Declaration
Swift
override open func update(_ currentTime: TimeInterval)
Parameters
currentTime
TimeInterval
update interval. -
Update the camera bounds.
Declaration
Swift
open func updateCamera()
-
Return a custom graph node type.
Declaration
Swift
open func objectForGraphType(named: String?) -> GKGridGraphNode.Type
Parameters
named
String
graph node type.Return Value
GKGridGraphNode.Type
dictionary insertion was successfull. -
Add a
GKGridGraph
instance to theSKTIledScene.graphs
property. Returns false if that name exists already.Declaration
Swift
open func addGraph(named: String, graph: GKGridGraph<GKGridGraphNode>) -> Bool
Parameters
named
String
name of graph.graph
GKGridGraph<GKGridGraphNode>
Return Value
Bool
dictionary insertion was successfull. -
Remove a named
GKGridGraph
from theSKTIledScene.graphs
property.Declaration
Swift
open func removeGraph(named: String) -> GKGridGraph<GKGridGraphNode>?
Parameters
named
String
name of graph.Return Value
GKGridGraph?
removed graph instance. -
Mouse click event handler.
Declaration
Swift
override open func mouseDown(with event: NSEvent)
Parameters
event
mouse event.
-
Mouse move event handler.
Declaration
Swift
override open func mouseMoved(with event: NSEvent)
Parameters
event
mouse event.
-
Mouse scroll wheel event handler.
Declaration
Swift
override open func scrollWheel(with event: NSEvent)
Parameters
event
mouse event.
-
Called when the scene receives a double-tap event (iOS only).
-
Called when the camera positon changes.
Declaration
Swift
@objc public func cameraPositionChanged(newPosition: CGPoint)
Parameters
newPositon
CGPoint
updated camera position. -
Called when the camera zoom changes.
Declaration
Swift
@objc public func cameraZoomChanged(newZoom: CGFloat)
Parameters
newZoom
CGFloat
camera zoom amount. -
Called when the camera bounds updated.
Declaration
Swift
@objc public func cameraBoundsChanged(bounds: CGRect, position: CGPoint, zoom: CGFloat)
Parameters
bounds
CGRect
camera view bounds.positon
CGPoint
camera position.zoom
CGFloat
camera zoom amount. -
Called when the scene is double-clicked (macOS only).
Declaration
Swift
@objc public func sceneDoubleClicked(event: NSEvent)
Parameters
event
NSEvent
mouse click event. -
Called when the mouse moves in the scene (macOS only).
Declaration
Swift
@objc public func mousePositionChanged(event: NSEvent)
Parameters
event
NSEvent
mouse click event.