API Reference › Anim › Anim.cell_y
method

Anim.cell_y

Anim.cell_y(frame, cols, cell_h) -> int

Turns a frame index into the top pixel of its cell on a spritesheet laid out as a grid of cols columns: (frame / cols) * cell_h. Pair with Anim.cell_x for the full source rectangle of the frame.

Parameters

framethe frame index (e.g. from Anim.frame)
colscolumns in the sheet
cell_hcell height in pixels

Example

program Demo {
  handler Run phase Update {
    let f  = Anim.frame(fixed(1), 12, 8)
    let sy = Anim.cell_y(f, 4, 16)
    print(sy)
  }
}
← All symbols