Class

SKTileDefinition

A single tile that can be repeated in a tile map.

Declaration

@interface SKTileDefinition : NSObject

Overview

To define the visual representation of a single tile, you create an SKTileDefinition object with texture and size information. Tile definitions support separate normal textures, for simulating 3D lighting, and arrays of textures for animation with speed controlled by the timePerFrame property. Textures can be rotated in 90˚ increments or flipped either vertically or horizontally.

Once a tile definition has been created, you encapsulate it in a SKTileGroup which is added to a SKTileSet which, in turn, is displayed in the scene with a SKTileMapNode.

Topics

Creating a Tile with a Texture

- initWithTexture:

Initializes a new tile definition with a single texture.

Creating a Tile with a Normal Texture

Create a tile with an additional texture that's used for lighting effects.

- initWithTexture:normalTexture:size:

Initializes a new tile definition with a single texture and separate normal texture for simulating 3D lighting.

Creating a Tile with a Size

- initWithTexture:size:

Initializes a new tile definition of a specified size with a single texture.

Creating an Animated Tile

Create an animated Tile by passing in an array of textures (animation frames) and their respective times per frame.

- initWithTextures:normalTextures:size:timePerFrame:

Initializes a new tile definition with arrays of textures and normal textures for animation.

- initWithTextures:size:timePerFrame:

Initializes a new tile definition with an array of textures for animation.

Flipping a Tile Vertically or Horizontally

flipHorizontally

A Boolean that flips the definition’s image vertically.

flipVertically

A Boolean that flips the definition’s image horizontally.

Rotating a Tile

rotation

The rotation of the tile definition in 90˚ increments.

SKTileDefinitionRotation

The allowed rotations for a given tile.

Configure Animated Tile Properties

textures

An array of SKTexture objects that defines the tile definition object's content.

normalTextures

An array of SKTexture objects used to generate the normals for the tile to simulate 3D lighting.

timePerFrame

The duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence.

Reading or Adding a Tile's Custom Data

userData

A dictionary containing arbitrary data.

Reading or Adjusting a Tile's Instance Properties

name

A name associated with the tile definition.

placementWeight

The placement weight of the tile definition.

size

The size of the tile definition in points.

Relationships

Inherits From

See Also

Tiling

SKTileMapNode

A two-dimensional array of images.

SKTileGroup

A set of tiles that collectively define one type of terrain.

SKTileGroupRule

Rules that describe how various tiles should be placed in a map.

SKTileSet

A container for related tile groups.