SKObjectGroup

public class SKObjectGroup : TiledLayerObject

The SKObjectGroup class is a container for vector object types. Most object properties can be set on the parent SKObjectGroup which is then applied to all child objects.

Properties

  • count: returns the number of objects in the layer.
  • showObjects: toggle visibility for all of the objects in the layer.
  • lineWidth: governs object line width for each object.
  • debugDrawOptions: debugging display flags.

Methods

  • addObject: add an object to the object group.
  • removeObject: remove an object from the object group.
  • getObject(withID:): returns an object with the given id, if it exists.

Usage

Adding a child object with optional color override:

objectGroup.addObject(myObject, withColor: SKColor.red)

Querying an object with a specific name:

let doorObject = objectGroup.getObject(named: "Door")

Returning objects of a certain type:

let rockObjects = objectGroup.getObjects(ofType: "Rock")
  • Returns the number of child objects contained in this layer.

    Declaration

    Swift

    public var count: Int { get }
  • Layer-based control for antialiasing child objects.

    Declaration

    Swift

    public override var antialiased: Bool { get set }
  • Governs object line width for each object.

    Declaration

    Swift

    public var lineWidth: CGFloat { get set }
  • Render scaling property.

    Declaration

    Swift

    public override var renderQuality: CGFloat { get set }
  • Speed modifier applied to all actions executed by the layer and its descendants.

    Declaration

    Swift

    public override var speed: CGFloat { get set }
  • Layer tint color.

    Declaration

    Swift

    public override var tintColor: SKColor? { get set }

Initialization

Objects

Tile Objects

Text Objects

Physics

Callbacks

  • Called when the layer is finished rendering.

    Declaration

    Swift

    public override func didFinishRendering(duration: TimeInterval = 0)

    Parameters

    duration

    transition duration.

Updating: Object Group

Updating

  • Update the object group before each frame is rendered.

    Declaration

    Swift

    public override func update(_ currentTime: TimeInterval)

    Parameters

    currentTime

    update interval.

Reflection

  • Returns a custom mirror for this layer.

    Declaration

    Swift

    public override var customMirror: Mirror { get }

Debug Descriptions

  • Returns the internal Tiled node type.

    Declaration

    Swift

    @objc
    public var tiledElementName: String { get }
  • Returns a “nicer” node name, for usage in the inspector.

    Declaration

    Swift

    @objc
    public override var tiledNodeNiceName: String { get }
  • Returns the internal Tiled node type icon.

    Declaration

    Swift

    @objc
    public override var tiledIconName: String { get }
  • A description of the node used in list or outline views.

    Declaration

    Swift

    @objc
    public override var tiledListDescription: String { get }
  • Returns a string representation for use with a dropdown menu.

    Declaration

    Swift

    @objc
    public override var tiledHelpDescription: String { get }

Deprecations

  • Returns an object with the given name.

    Declaration

    Swift

    @available(*, deprecated, message: "use `getObjects(named:recursive:﹚` instead")
    public func getObject(named: String) -> SKTileObject?

    Parameters

    named

    Object name.

    Return Value

    object matching the given name.

  • Render all of the objects in the group.

    Declaration

    Swift

    @available(*, deprecated, renamed: "draw(﹚")
    public func drawObjects()
  • Return tile object(s) matching the given global id.

    Declaration

    Swift

    @available(*, deprecated, renamed: "tileObjects(globalID:﹚")
    public func tileObjects(globalID: Int) -> [SKTileObject]

    Parameters

    globalID

    global id to query.

    Return Value

    array of matching tile objects.

  • Returns an object with the given id.

    Declaration

    Swift

    @available(*, deprecated, renamed: "getObject(withID:﹚")
    public func getObject(withID id: Int) -> SKTileObject?

    Parameters

    id

    Object id.

    Return Value

    vector object.

SKObjectGroup

  • Parse the object group’s properties.

    Declaration

    Swift

    public override func parseProperties(completion: (() -> Void)?)

    Parameters

    completion

    optional completion closure.