TiledMappableGeometryType

@objc
public protocol TiledMappableGeometryType : TiledGeometryType

The TiledMappableGeometryType protocol describes a container that is broken up into two-dimensional tiles.

Properties

  • orientation: Container orientation
  • isInfinite: Container represents and infinite area.
  • mapSize: Container size (in tiles)
  • graph: Container pathfinding graph (optional)
  • childOffset: Child node offset (optional)
  • tileSize: Tile size (in pixels)
  • hexsidelength: Hexagonal side length
  • staggeraxis: Hexagonal stagger axis
  • staggerindex: Hexagonal stagger index

Sizing

  • width Extension method

    Returns the width (in tiles) of the container.

    Declaration

    Swift

    public var width: CGFloat { get }
  • height Extension method

    Returns the height (in tiles) of the container.

    Declaration

    Swift

    public var height: CGFloat { get }
  • sizeHalved Extension method

    Returns the size (in tiles) of the container halved.

    Declaration

    Swift

    public var sizeHalved: CGSize { get }
  • tileWidth Extension method

    Returns the tile width (in pixels) value.

    Declaration

    Swift

    public var tileWidth: CGFloat { get }
  • tileHeight Extension method

    Returns the tile height (in pixels) value.

    Declaration

    Swift

    public var tileHeight: CGFloat { get }
  • tileSizeHalved Extension method

    Returns the tile size (in pixels) of the container halved.

    Declaration

    Swift

    public var tileSizeHalved: CGSize { get }
  • tileWidthHalf Extension method

    Returns the tile size width (in pixels), halved.

    Declaration

    Swift

    public var tileWidthHalf: CGFloat { get }

    Return Value

    tile size half-width.

  • tileHeightHalf Extension method

    Returns the tile size height (in pixels), halved.

    Declaration

    Swift

    public var tileHeightHalf: CGFloat { get }

    Return Value

    tile size half-height.

  • sizeInPoints Extension method

    Returns the size of the container, in points.

    Declaration

    Swift

    public var sizeInPoints: CGSize { get }
  • sizeInPixels Extension method

    The size of the container, in pixels.

    Declaration

    Swift

    public var sizeInPixels: CGSize { get }

Geometry

Helpers

  • staggerX Extension method

    Indicates the x-axis should be staggered.

    Declaration

    Swift

    public var staggerX: Bool { get }
  • staggerEven Extension method

    Indicates even rows should be staggered.

    Declaration

    Swift

    public var staggerEven: Bool { get }
  • sideLengthX Extension method

    Returns the side length for flat hexagons.

    Declaration

    Swift

    public var sideLengthX: CGFloat { get }
  • sideLengthY Extension method

    Returns the side length for pointy hexagons.

    Declaration

    Swift

    public var sideLengthY: CGFloat { get }
  • sideOffsetX Extension method

    Returns the side offset in x.

    Declaration

    Swift

    public var sideOffsetX: CGFloat { get }

Coordinate Conversion

  • Returns a screen point for a given coordinate in the object (layer or map), with optional offset values for x/y.

    Declaration

    Swift

    public func pointForCoordinate(coord: simd_int2,
                                   offsetX: CGFloat = 0,
                                   offsetY: CGFloat = 0) -> CGPoint

    Parameters

    coord

    tile coordinate.

    offsetX

    x-offset value.

    offsetY

    y-offset value.

    Return Value

    point in layer (spritekit space).

  • coordinateForPoint(point:) Extension method

    Returns a tile coordinate for a given screen point in the object (layer or map).

    Declaration

    Swift

    public func coordinateForPoint(point: CGPoint) -> simd_int2

    Parameters

    point

    point in layer (spritekit space).

    Return Value

    tile coordinate.

Extensions

  • shaderUniforms Extension method

    Returns an array of shader unforms based on the current attributes.

    Declaration

    Swift

    public var shaderUniforms: [SKUniform] { get }

Available where Self: SKNode

  • parents Extension method

    Returns an array of parent layers, beginning with the current.

    Declaration

    Swift

    public var parents: [SKNode] { get }
  • Add an SKNode child node at the given coordinates. By default, the zPositon will be higher than all of the other nodes in the layer.

    Declaration

    Swift

    public func addChild(_ node: SKNode,
                         coord: simd_int2,
                         offset: CGPoint = CGPoint.zero,
                         zpos: CGFloat? = nil)

    Parameters

    node

    SpriteKit node.

    coord

    map coordinate.

    offset

    offset amount.

    zpos

    optional z-position.

  • addChild(_:x:y:offset:zpos:) Extension method

    Add an SKNode child node at the given x/y coordinates. By default, the zPositon will be higher than all of the other nodes in the layer.

    Declaration

    Swift

    public func addChild(_ node: SKNode,
                         x: Int = 0,
                         y: Int = 0,
                         offset: CGPoint = CGPoint.zero,
                         zpos: CGFloat? = nil)

    Parameters

    node

    object.

    x

    map x-coordinate.

    y

    map y-coordinate.

    offset

    offset amount.

    zpos

    optional z-position.

  • addChild(_:_:_:dx:dy:zpos:) Extension method

    Add a node at the given coordinates. By default, the zPositon will be higher than all of the other nodes in the layer.

    Declaration

    Swift

    public func addChild(_ node: SKNode,
                         _ x: Int,
                         _ y: Int,
                         dx: CGFloat = 0,
                         dy: CGFloat = 0,
                         zpos: CGFloat? = nil)

    Parameters

    node

    SpriteKit node.

    x

    map x-coordinate.

    y

    map y-coordinate.

    dx

    offset x-amount.

    dy

    offset y-amount.

    zpos

    z-position (optional).