godot-2d

Installation
SKILL.md

2D in Godot 4.7

Movement physics lives in godot-physics, UI in godot-ui, shaders in godot-shaders-vfx. Look up any API with ../godot-core/scripts/api_lookup.py.

Project setup

Style Settings
Pixel art rendering/textures/canvas_textures/default_texture_filter = 0 (Nearest); display/window/stretch/mode = "viewport", scale_mode = "integer", aspect keep/expand; base size small (for example 320×180 or 640×360); optionally rendering/2d/snap/snap_2d_transforms_to_pixel = true
HD 2D / UI-heavy stretch mode canvas_items (the 4.7 default for new projects), aspect expand, base size 1920×1080 or 1280×720, Linear filter
Never mix texel sizes in pixel-art games. Scale sprites by whole numbers only.

TileMapLayer (TileMap is deprecated)

  • Use one TileMapLayer node per layer (ground, walls, decoration), all sharing one TileSet resource. Old TileMap nodes convert through the TileMap panel's toolbox: "Extract TileMap layers".
  • Code: set_cell(coords, source_id, atlas_coords, alternative), erase_cell, get_cell_source_id (−1 means empty), get_cell_atlas_coords, get_used_cells(), get_used_cells_by_id(), local_to_map(to_local(global_pos)), map_to_local(cell).
  • Per-tile metadata: add custom data layers to the TileSet (is_hazard: bool, cost: float), then read them with get_cell_tile_data(cell).get_custom_data("is_hazard").
  • Autotiling: set up terrain sets in the TileSet, then call set_cells_terrain_connect(cells, terrain_set, terrain) or set_cells_terrain_path.
  • Collision, navigation and occlusion come from the TileSet's physics, navigation and occlusion layers. Physics shapes are merged into chunks (physics_quadrant_size, default 16). Set it to 1 only if you need get_coords_for_body_rid per cell.
  • For changes at runtime, set the cells, then update_internals() if you need them immediately. Per-cell runtime variations use _use_tile_data_runtime_update and _tile_data_runtime_update with notify_runtime_tile_data_update().
  • Large worlds: use chunked layers per region and free distant chunks. Thousands of set_cell calls in one frame stall, so spread them over several frames.
Installs
11
GitHub Stars
54
First Seen
8 days ago