Skip to content

TileMap ​

A grid of tiles from one tile set image, with solid tiles that block movement in a World2D.

Inherits Instance.

Made with Instance.new("TileMap").

Properties ​

NameTypeNotes
CanCollidebooleanWhether its solid tiles block World2D:Move.
CanQuerybooleanWhether raycasts and overlap queries find its solid tiles.
CellSizeVector2The size of one cell in the world. Zero means TileSize.
CellsstringEvery cell as x,y,tile entries separated by semicolons, as places save them.
ColorColorTints every tile.
ColumnsnumberTiles to a row of the tile set. Zero fits as many as the image is wide.
PixelatedbooleanDraws pixel art crisp when true, and smooths it when false.
PositionVector2Where the top left of cell 0, 0 is in the world.
SolidTilesstringThe solid tile numbers separated by commas.
TileSetstringThe tile set image, relative to the project, or an http URL. A URL needs the Http permission.
TileSizeVector2The size of one tile in the image, in pixels.
TransparencynumberFrom 0, opaque, to 1, invisible.
VisiblebooleanWhether it is drawn. Hidden tiles still collide.
ZIndexnumberHigher draws on top of sprites and other maps.

Methods ​

  • CellToWorld(cell: Vector2): Vector2: The top left corner of a cell in the world.
  • Clear(): (): Empties every cell.
  • Fill(from: Vector2, to: Vector2, tile: number): (): Puts a tile in every cell of a rectangle, corners included.
  • GetCell(x: number, y: number): number: The tile in a cell, or -1 for an empty one.
  • GetUsedCells(): {Vector2}: The cells that hold a tile.
  • IsCellSolid(x: number, y: number): boolean: Whether a cell holds a solid tile.
  • IsTileSolid(tile: number): boolean: Whether a tile number is solid.
  • SetCell(x: number, y: number, tile: number): (): Puts a tile in a cell, or empties it with -1.
  • SetTileSolid(tile: number, solid: boolean?): (): Marks a tile number solid, or not.
  • WorldToCell(position: Vector2): Vector2: The cell holding a point in the world.

Inherited ​

From Instance: AddTag, AncestryChanged, Archivable, AttributeChanged, Changed, ChildAdded, ChildRemoved, ClassName, ClearAllChildren, Clone, DescendantAdded, DescendantRemoving, Destroy, Destroying, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, GetDescendants, GetFullName, GetPropertyChangedSignal, GetTags, HasTag, IsA, IsAncestorOf, IsDescendantOf, IsPropertyModified, Name, Parent, QueryDescendants, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild.

Apache License 2.0