Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class TileLayerCollision

  1. Object
  2. TileLayerCollision

Converts between a drawn com.codename1.gaming.level.TileLayer and the collision TileGrid the simulation reads.

A game painting its levels with an atlas keeps one table, “frame N of the sheet is solid, frame M is a one-way ledge”, and derives the collision from the art with #toGrid; a game that writes Tile characters derives the art from the collision with #toLayer.

Methods

public static TileGrid toGrid(TileLayer layer, int[] frameKinds)Builds the collision grid for a tile layer.
public static TileLayer toLayer(TileGrid grid, SpriteSheet sheet, int[] kindFrames)Builds a tile layer that draws a collision grid.

Inherited methods

Method details

toGrid

public static TileGrid toGrid(TileLayer layer, int[] frameKinds)
Builds the collision grid for a tile layer.

Parameters

layer TileLayer
the drawn layer
frameKinds int[]
the Tile kind of each sheet frame; frames past the end and empty cells are Tile#EMPTY

Returns

a grid of the same size and tile size

toLayer

public static TileLayer toLayer(TileGrid grid, SpriteSheet sheet, int[] kindFrames)
Builds a tile layer that draws a collision grid.

Parameters

grid TileGrid
the grid
sheet SpriteSheet
the tileset
kindFrames int[]
the sheet frame for each Tile kind, indexed by kind; -1 or past the end draws nothing

Returns

the layer