User Tools

Site Tools


docs:mapmanager

Table of Contents

The MapManager service provides access to several commonly used operations involving the map. You can get an instance of the MapManager at Services.MapManager.

The MapManager also keeps a list of all of the TileMaps that are being used to draw the scene. Tileset scenes should register their TileMap nodes with the MapManager service using the register_map() method. TileMaps are automatically unregistered when the scene is changed. Additionally TileMaps should have their global position set to Vector2(0,0) and have a cell_size that matches or is a clean multiple of Services.MapManager.cell_size().

Class Reference

Enums

  • Corners {UPPER_LEFT, UPPER_RIGHT, LOWER_LEFT, LOWER_RIGHT}
  • Sides {TOP, RIGHT, BOTTOM, LEFT}

Methods

  • world_to_map(position: Vector2) → Vector2
    • Converts between global positions and map positions
  • map_to_world(position: Vector2) → Vector2
    • Converts between map positions and global positions
  • cell_size() → Vector2
    • Returns the size of the cells on the map
  • tile_bounding_box(position: Vector2) → Array
    • Returns the global position of each corner of a tile
  • center_of_tile(position: Vector2) → Vector2
    • Returns the global position of the center of the tile
  • position_in_tile(position: Vector2, tile: Vector2) → bool
    • Determines if a global position is in a given map tile
  • near_edge_of_tile(position: Vector2, tile: Vector2, threshold: float)
    • Determines if a global position is near the edge of a tile
  • interactables_on_tile(position: Vector2) → Array
    • Returns an Array with all valid interactable objects on a tile
  • register_map(new_map: TileMap, registered_name: String)
    • Registers a background TileMap
  • unregister_map(registered_name: String)
    • Unregisters a previously registered background TileMap
  • get_registered_maps() → Dictionary
    • Returns a list of all registered maps by name
docs/mapmanager.txt · Last modified: 2021/03/12 17:55 by 60.8.123.201