TileID
@propertyWrapper
public struct TileID
The TileID
structure provides an interface to a masked tile id.
Tile flipping is represented by a mask of a tile global id, with the upper three bits storing orientation values (flipped horizontally, flipped vertically, flipped diagonally).
Usage
This structure is not meant to be used directly; simply passing a value to the SKTile.tileId
property will set the global id and orientation of the tile.
See the Working with Tiles documentation for more information.
// A raw value of 2147483659 translates to 11, flipped horizontally.
let gid: UInt32 = 2147483659
var tileId = TileID(wrappedValue: 2147483659)
print(tileId)
// Tile ID: 11, flags: [ hFlip ]
// Alternately, we can set the flags directly:
tileId.flags = [.all]
print(tileId)
// Tile ID: 11, flags: [ hFlip, vFlip, dFlip ]
-
Associated tile flip flags.
Declaration
Swift
public var flags: TileFlags { get set }
-
Instantiate with a global ID value. The
wrappedValue
argument can be either a global id, or a masked global id.Declaration
Swift
public init(wrappedValue: UInt32)
Parameters
id
tile global id.
-
Default initializer.
Declaration
Swift
public init()
-
The unmasked tile id.
Declaration
Swift
public var wrappedValue: UInt32 { get set }
-
Returns the masedk tile id (including flip flags) value.
Declaration
Swift
public var realValue: UInt32 { get }
-
Tile is flipped horizontally.
Declaration
Swift
public var isFlippedHorizontally: Bool { get set }
-
Tile is flipped vertically.
Declaration
Swift
public var isFlippedVertically: Bool { get set }
-
Tile is flipped diagonally.
Declaration
Swift
public var isFlippedDiagonally: Bool { get set }