API Reference › Anim › Anim.cell_x
method

Anim.cell_x

Anim.cell_x(frame, cols, cell_w) -> int

Turns a frame index into the left pixel of its cell on a spritesheet laid out as a grid of cols columns: (frame mod cols) * cell_w. Combine with Anim.cell_y to get the top-left source coordinate to blit from.

Parameters

framethe frame index (e.g. from Anim.frame)
colscolumns in the sheet
cell_wcell width in pixels

Example

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