Globals

SKTiled globals are accessible via the TiledGlobals object. This structure enables the user to set default values for various API objects, as well as enable/disable debugging functions.

// Access the default `TiledGlobals` singleton
let globals = TiledGlobals.default

Aliases

  • ▶︎TiledGlobals

    Overview

    The TiledGlobals object provides information about the framework, as well as allowing you to set default SKTiled attributes.

    Properties

    Property Description
    renderer Returns the current SpriteKit renderer (get-only).
    loggingLevel Logging verbosity.
    updateMode Default tile update mode.
    enableRenderCallbacks Enable callbacks from the tilemap on rendering statistics.
    enableCameraCallbacks Enable callbacks from camera to camera delegates.
    renderQuality Global render quality values.
    contentScale Returns the device retina display scale factor.
    version Returns the current framework version.

    Usage

    SKTiled object default values are set in the TiledGlobals object.

    // access the default singleton instance
    let tiledGlobals = TiledGlobals.default
    
    // disable camera callbacks
    tiledGlobals.enableCameraCallbacks = false
    
    // set debugging mouse filters (macOS)
    tiledGlobals.debug.mouseFilters = [.tileCoordinates, .tilesUnderCursor]
    
    // increase the default text object render quality
    tiledGlobals.renderQuality.text = 12.0
    
    See more

    Declaration

    Swift

    public class TiledGlobals
  • Overview

    Determines how an attached controller interacts with the camera.

    Properties

    Property Description
    none Controller does not affect camera.
    dolly Controller pans the camera.
    zoom Controller changes the camera zoom.

    Declaration

    Swift

    public enum CameraControlMode : Int
  • Overview

    Camera zoom rounding factor. Clamps the zoom value to the nearest whole pixel value in order to alleviate cracks appearing in between individual tiles.

    Properties

    Property Description
    none Do not clamp camera zoom.
    half Clamp zoom to the nearest half-pixel.
    third Clamp zoom to the nearest third of a pixel.
    See more

    Declaration

    Swift

    public enum CameraZoomClamping : CGFloat
  • Overview

    The TileRenderMode flag determines how a particular tile instance is rendered. If the default is specified, the tile renders however the parent tilemap tells it to. Only set this flag to override a particular tile instance’s render behavior.

    Properties

    Property Description
    default Tile renders at default settings.
    static Tile ignores any animation data.
    ignore Tile does not take into account its tile data.
    animated Animate with a global id value.
    See more

    Declaration

    Swift

    public enum TileRenderMode
    extension TileRenderMode: CustomStringConvertible, CustomDebugStringConvertible
    extension TileRenderMode: Equatable
  • Overview

    Describes how the tilemap updates its tiles in your scene. Changing this property will affect your CPU usage, so use it carefully.

    The default mode is TileUpdateMode.dynamic, which updates tiles as needed each frame. For best performance, use TileUpdateMode.actions, which will run SpriteKit actions on animated tiles.

    Usage

    // passing the tile update mode to the load function
    let tilemap = SKTilemap.load(tmxFile: String, updateMode: TileUpdateMode.dynamic)!
    
    // updating the attribute on the tilemp node
    tilemap.updateMode = TileUpdateMode.actions
    

    Properties

    Property Description
    dynamic Dynamically update tiles as needed.
    full All tiles are updated each frame.
    actions Tiles are not updated, SpriteKit actions are used instead.
    See more

    Declaration

    Swift

    public enum TileUpdateMode : Int
    extension TileUpdateMode: CustomStringConvertible, CustomDebugStringConvertible
  • Overview

    Structure for managing basic font rendering attributes for text objects.

    Properties

    Property Description
    fontName Font name.
    fontSize Font size.
    fontColor Font color.
    alignment Horizontal/vertical text alignment.
    wrap Text wraps.
    isBold Text is bold.
    isItalic Text is italicized.
    isunderline Text is underlined.
    renderQuality Font scaling attribute.
    See more

    Declaration

    Swift

    public struct TextObjectAttributes