SKGroupLayer
public class SKGroupLayer : SKTiledLayerObject
Overview
Subclass of SKTiledLayerObject
, the group layer is a container for managing groups of layers.
Usage
Query child layers:
for child in group.layers {
child.opacity = 0.5
}
Add layers to the group with:
groupLayer.addLayer(playerLayer)
Remove with:
groupLayer.removeLayer(playerLayer)
-
Returns the last index for all layers.
Declaration
Swift
public var lastIndex: Int { get }
-
Returns the last (highest) z-position in the map.
Declaration
Swift
public var lastZPosition: CGFloat { get }
-
▶︎layers
Returns a flattened array of child layers.
Declaration
Swift
override public var layers: [SKTiledLayerObject] { get }
-
Returns all layers, sorted by index (first is lowest, last is highest).
Declaration
Swift
public func allLayers() -> [SKTiledLayerObject]
Return Value
[SKTiledLayerObject]
array of layers. -
Returns an array of layer names.
Declaration
Swift
public func layerNames() -> [String]
Return Value
[String]
layer names. -
Add a layer to the layers set. Automatically sets zPosition based on the tilemap zDeltaForLayers attributes.
Declaration
Swift
@discardableResult public func addLayer(_ layer: SKTiledLayerObject, clamped: Bool = true) -> (success: Bool, layer: SKTiledLayerObject)
Parameters
layer
SKTiledLayerObject
layer object.clamped
Bool
clamp position to nearest pixel.Return Value
(success: Bool, layer: SKTiledLayerObject)
add was successful, layer added. -
Remove a layer from the current layers set.
Declaration
Swift
public func removeLayer(_ layer: SKTiledLayerObject) -> SKTiledLayerObject?
Parameters
layer
SKTiledLayerObject
layer object.Return Value
SKTiledLayerObject?
removed layer.
-
Update the group layer before each frame is rendered.
Declaration
Swift
override public func update(_ currentTime: TimeInterval)
Parameters
currentTime
TimeInterval
update interval.