Cauldron2D.GameMaker.Sprite (Cauldron2D.GameMaker v0.2.1)

Copy Markdown View Source

A sprite (a SPRT entry): frames of a picture, the point it is drawn from, and the masks it collides with.

  • size is {width, height}; every frame is a Cauldron2D.GameMaker.Region whose bounds are that size
  • origin is {x, y}, the pixel placed at an instance's position
  • box is the collision box {left, top, right, bottom}, inclusive, in the picture's pixels; box_mode says how it was chosen (0 automatic, 1 the whole picture, 2 set by hand)
  • masks holds one Cauldron2D.Mask per frame when separate_masks is set, otherwise one for every frame; mask/2 gives a frame's
  • speed is {rate, :per_second | :per_frame}, the animation's playback; GameMaker Studio 1 files carry none and are {1.0, :per_frame}

  • kind is :bitmap, :vector or :spine; only a bitmap sprite has frames

Summary

Functions

The mask frame frame collides with, nil for a sprite with no masks.

The sprite at at, its frames looked up in regions by offset.

Types

t()

@type t() :: %Cauldron2D.GameMaker.Sprite{
  box: {integer(), integer(), integer(), integer()},
  box_mode: non_neg_integer(),
  frames: [Cauldron2D.GameMaker.Region.t()],
  kind: :bitmap | :vector | :spine,
  masks: [Cauldron2D.Mask.t()],
  name: String.t(),
  origin: {integer(), integer()},
  separate_masks: boolean(),
  size: {non_neg_integer(), non_neg_integer()},
  smooth: boolean(),
  speed: {float(), :per_second | :per_frame}
}

Functions

mask(sprite, frame)

@spec mask(t(), integer()) :: Cauldron2D.Mask.t() | nil

The mask frame frame collides with, nil for a sprite with no masks.

read(data, at, regions)

@spec read(binary(), non_neg_integer(), %{
  required(non_neg_integer()) => Cauldron2D.GameMaker.Region.t()
}) :: t()

The sprite at at, its frames looked up in regions by offset.