Cauldron2D.GameMaker.TileLayers (Cauldron2D.GameMaker v0.2.1)

Copy Markdown View Source

A room's tile layers, each drawn as one picture.

Cauldron2D.GameMaker.Draw.run/1 gives a visible layer's tiles as one draw list item (item/4) whose picture is {:tile_layer, room, layer, blend}: the room's index, the layer's name, and the colour Cauldron2D.GameMaker.World.put_layer/3's :tile_blend gave an asset layer's tiles, or nil. It stands at the layer's offset plus the top-left corner of its tiles. raster/3 draws that picture from the game's data: every tile as the layer would draw it on its own, mirrored, flipped and turned as its cell says, in its colour and alpha. A key always names the same pixels, so a picture drawn once can be kept and drawn again.

raster = Cauldron2D.GameMaker.TileLayers.raster(data, key, &MyGame.picture/1)

Summary

Functions

The draw list item for the tiles of layer, a layer of room room already moved to where it is drawn, its asset tiles blended blend (or nil); nil when it has no tiles.

The picture key names, drawn with pictures (a function from a tile's picture key, {:tile, background, tile} or {:sprite_part, sprite, rectangle}, to its raster); nil when the room has no such layer or the layer no tiles.

Types

key()

@type key() ::
  {:tile_layer, non_neg_integer(), String.t(), {byte(), byte(), byte()} | nil}

Functions

item(data, room, layer, blend)

The draw list item for the tiles of layer, a layer of room room already moved to where it is drawn, its asset tiles blended blend (or nil); nil when it has no tiles.

raster(data, arg, pictures)

@spec raster(Cauldron2D.GameMaker.Data.t(), key(), (term() ->
                                                FrenchCurve.Raster.t() | nil)) ::
  FrenchCurve.Raster.t() | nil

The picture key names, drawn with pictures (a function from a tile's picture key, {:tile, background, tile} or {:sprite_part, sprite, rectangle}, to its raster); nil when the room has no such layer or the layer no tiles.