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 }
-
Instantiate the node with a decoder instance.
Declaration
Swift
required public init?(coder aDecoder: NSCoder)
Parameters
aDecoder
decoder.
-
Add an
SKTileObject
vector object to the objects set.Declaration
Swift
public func addObject(_ object: SKTileObject, withColor: SKColor? = nil) -> SKTileObject?
Parameters
object
object instance.
withColor
optional override color (otherwise defaults to parent layer color).
Return Value
added object.
-
Remove an
SKTileObject
object from the object set.Declaration
Swift
public func removeObject(_ object: SKTileObject) -> SKTileObject?
Parameters
object
object instance.
Return Value
removed object.
-
Render all of the objects in the group.
Declaration
Swift
public func draw()
-
Set the color for all objects.
Declaration
Swift
public override func setColor(color: SKColor)
Parameters
color
object color.
-
Set the color for all objects.
Declaration
Swift
public override func setColor(hexString: String)
Parameters
hexString
color hex vale.
-
Returns an array of object names.
Declaration
Swift
public func objectNames() -> [String]
Return Value
object names in the layer.
-
Returns an object with the given id.
Declaration
Swift
public func getObject(withID id: UInt32) -> SKTileObject?
Parameters
id
Object id.
Return Value
vector object.
-
Returns text objects with matching text.
Declaration
Swift
public func getObjects(withText text: String) -> [SKTileObject]
Parameters
text
text string to match.
Return Value
array of matching objects.
-
Returns objects with the given name.
Declaration
Swift
public func getObjects(named: String) -> [SKTileObject]
Parameters
named
Object name.
Return Value
array of matching objects.
-
Returns all child objects contained in the layer.
Declaration
Swift
public func getObjects() -> [SKTileObject]
Return Value
array of child objects.
-
Returns objects of a given type.
Declaration
Swift
public func getObjects(ofType: String) -> [SKTileObject]
Parameters
ofType
object type.
Return Value
array of matching objects.
-
Returns objects at the given screen position.
Declaration
Swift
public func objectsAt(point: CGPoint) -> [SKTileObject]
Parameters
point
screen point.
Return Value
objects at the given point.
-
Returns objects at the given coordinate.
Declaration
Swift
public func objectsAt(coord: simd_int2) -> [SKTileObject]
Parameters
point
map coordinate.
Return Value
objects at the given point.
-
Returns an array of objects representing tile objects.
Declaration
Swift
public func tileObjects() -> [SKTileObject]
Return Value
objects with a tile gid.
-
Return tile object(s) matching the given global id.
Declaration
Swift
public func tileObjects(globalID: UInt32) -> [SKTileObject]
Parameters
globalID
global id to query.
Return Value
array of matching tile objects.
-
Create and add a tile object with the given tile data.
Declaration
Swift
public func newTileObject(data: SKTilesetData) -> SKTileObject
Parameters
data
tile data.
Return Value
created tile object.
-
Returns an array of textual objects.
Declaration
Swift
public func textObjects() -> [SKTileObject]
Return Value
text objects.
-
Setup tile collisions for each object.
Declaration
Swift
public override func setupTileCollisions()
-
Called when the layer is finished rendering.
Declaration
Swift
public override func didFinishRendering(duration: TimeInterval = 0)
Parameters
duration
transition duration.
-
Run animation actions on all of the tile objects in this layer.
Declaration
Swift
public override func runAnimationAsActions()
-
Remove tile object animation.
Declaration
Swift
public override func removeAnimationActions(restore: Bool = false)
Parameters
restore
restore tile/object texture.
-
Update the object group before each frame is rendered.
Declaration
Swift
public override func update(_ currentTime: TimeInterval)
Parameters
currentTime
update interval.
-
Returns a custom mirror for this layer.
Declaration
Swift
public override var customMirror: Mirror { get }
-
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 }
-
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.
-
Parse the object group’s properties.
Declaration
Swift
public override func parseProperties(completion: (() -> Void)?)
Parameters
completion
optional completion closure.