SKObjectGroup
public class SKObjectGroup : SKTiledLayerObject
Overview
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
| Property | Description |
|---|---|
| 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
| Method | Description |
|---|---|
| addObject | Returns the number of objects in the layer. |
| removeObject | Toggle visibility for all of the objects in the layer. |
| 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")
-
Toggle visibility for all of the objects in the layer.
Declaration
Swift
public var showObjects: Bool { get set } -
▶︎countReturns the number of objects in this layer.
Declaration
Swift
public var count: Int { get } -
Controls antialiasing for each object
Declaration
Swift
override public 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
override public var renderQuality: CGFloat { get set } -
Debug visualization options.
Declaration
Swift
override public var debugDrawOptions: DebugDrawOptions { get set }
-
Add an
SKTileObjectobject to the objects set.Declaration
Swift
public func addObject(_ object: SKTileObject, withColor: SKColor? = nil) -> SKTileObject?Parameters
objectSKTileObjectobject.withColorSKColor?optional override color (otherwise defaults to parent layer color).Return Value
SKTileObject?added object. -
Remove an
SKTileObjectobject from the object set.Declaration
Swift
public func removeObject(_ object: SKTileObject) -> SKTileObject?Parameters
objectSKTileObjectobject.Return Value
SKTileObject?removed object. -
▶︎draw()Render all of the objects in the group.
Declaration
Swift
public func draw() -
Set the color for all objects.
Declaration
Swift
override public func setColor(color: SKColor)Parameters
colorSKColorobject color.forceBoolforce color on objects that have an override. -
Set the color for all objects.
Declaration
Swift
override public func setColor(hexString: String)Parameters
colorSKColorobject color.forceBoolforce color on objects that have an override. -
Returns an array of object names.
Declaration
Swift
public func objectNames() -> [String]Return Value
[String]object names in the layer. -
Returns an object with the given id.
Declaration
Swift
public func getObject(withID id: Int) -> SKTileObject?Parameters
idIntObject id.Return Value
SKTileObject? -
Return text objects with matching text.
Declaration
Swift
public func getObjects(withText text: String) -> [SKTileObject]Parameters
withTextStringtext string to match.Return Value
[SKTileObject]array of matching objects. -
Return objects with the given name.
Declaration
Swift
public func getObjects(named: String) -> [SKTileObject]Parameters
namedStringObject name.Return Value
[SKTileObject]array of matching objects. -
Return all child objects.
Declaration
Swift
public func getObjects() -> [SKTileObject]Return Value
[SKTileObject]array of matching objects. -
Return objects of a given type.
Declaration
Swift
public func getObjects(ofType: String) -> [SKTileObject]Parameters
typeStringobject type.Return Value
[SKTileObject]array of matching objects.
-
Return tile objects.
Declaration
Swift
public func tileObjects() -> [SKTileObject]Return Value
[SKTileObject]objects with a tile gid. -
Return tile object(s) matching the given global id.
Declaration
Swift
public func tileObjects(globalID: Int) -> [SKTileObject]Parameters
globalIDIntglobal id to query.Return Value
SKTileObject?removed object. -
Create and add a tile object with the given tile data.
Declaration
Swift
public func newTileObject(data: SKTilesetData) -> SKTileObjectParameters
dataSKTilesetData` tile data.
Return Value
SKTileObjectcreated tile object.
-
Return text objects.
Declaration
Swift
public func textObjects() -> [SKTileObject]Return Value
[SKTileObject]text objects.
-
Called when the layer is finished rendering.
Declaration
Swift
override public func didFinishRendering(duration: TimeInterval = 0)Parameters
durationTimeIntervalfade-in duration.
-
Run animation actions on all tile objects.
Declaration
Swift
override public func runAnimationAsActions() -
Remove tile object animation.
Declaration
Swift
override public func removeAnimationActions(restore: Bool = false)Parameters
restoreBoolrestore tile/obejct texture.
-
Update the object group before each frame is rendered.
Declaration
Swift
override public func update(_ currentTime: TimeInterval)Parameters
currentTimeTimeIntervalupdate interval.
-
Returns an object with the given name.
Declaration
Swift
@available(*, deprecated, message: "use `getObjects(named:,recursive:﹚` instead") public func getObject(named: String) -> SKTileObject?Parameters
namedStringObject name.Return Value
SKTileObject? -
Render all of the objects in the group.
Declaration
Swift
@available(*, deprecated, renamed: "SKObjectGroup.draw(﹚") public func drawObjects() -
Parse the object group’s properties.
Declaration
Swift
override public func parseProperties(completion: (() -> Void)?)
View on GitHub
SKObjectGroup Class Reference