agentleFS
EL4CTEOEL4CTEO/godot-skills/skills/godot-2d/SKILL.md

godot-2d

Skill54 starsChanged 14 days agoMITView on GitHub

2D games in Godot 4.7 - pixel-art and HD setup, TileMapLayer (cells, terrains, custom data, runtime tiles, physics chunking), Parallax2D, Camera2D (limits, smoothing, shake), y-sort and z-index, 2D lights and normal maps, AnimatedSprite2D, one-way platforms, custom drawing, many-sprite performance. Use for platformers, top-down, tile-based or any 2D scene.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never mix texel sizes in pixel-art games.

    line 20
  2. Very specific:

    Use one TileMapLayer node per layer (ground, walls, decoration), all sharing one TileSet resource.

    line 23
  3. Very specific:

    Use one active camera per viewport (make_current()).

    line 34
  4. Very specific:

    Add Parallax2D nodes anywhere, with a Sprite2D or TextureRect as child.

    line 37
  5. Very specific:

    Use AnimationPlayer when frames must sync with hitboxes, sounds or method calls.

    line 49

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
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

StyleSettings
Pixel artrendering/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-heavystretch 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.

Camera2D

  • position_smoothing_enabled and position_smoothing_speed smooth the follow. Limits are limit_left/top/right/bottom (toggle them all with limit_enabled). drag_*_enabled adds a dead zone.
  • Screen shake: animate offset (not position) with decaying noise. See the reference.
  • Use one active camera per viewport (make_current()). Zoom uses zoom (Vector2: >1 zooms in).

Parallax2D (replaces ParallaxBackground/Layer)

Add Parallax2D nodes anywhere, with a Sprite2D or TextureRect as child. Set scroll_scale (0 = static, 1 = moves with the world), repeat_size = texture size for infinite tiling, repeat_times for zoomed-out cameras and autoscroll for clouds. It follows the active Camera2D automatically.

Drawing order

  • y_sort_enabled on the parent sorts its children by Y (top-down games). Each child's sort origin is its own origin, so put sprite feet at y=0.
  • z_index (relative to the parent unless z_as_relative = false) works across siblings. CanvasLayer handles HUD and backgrounds independently of the camera.
  • CanvasGroup renders a subtree as one unit, which lets outline shaders and transparency apply to a whole character.

Lights and atmosphere

PointLight2D (textured) and DirectionalLight2D, plus LightOccluder2D for shadows (TileSets can carry occluders). CanvasModulate darkens the scene. Normal and specular maps go through a CanvasTexture used as the sprite texture. Light2D is per-pixel, so keep lights overlapping any given sprite in the single digits on mobile.

Sprites and animation

  • AnimatedSprite2D + SpriteFrames handles frame animation (play(&"run"), animation_finished). Since 4.7, per-animation loop mode uses SpriteFrames.set_animation_loop_mode.
  • Use AnimationPlayer when frames must sync with hitboxes, sounds or method calls. Keyframe the frame property of a Sprite2D with hframes/vframes.
  • Sprite sheets: Sprite2D.region_enabled + region_rect, or AtlasTexture.

Platformer specifics

  • One-way platforms: CollisionShape2D.one_way_collision = true. 4.7 adds one_way_collision_direction (default Vector2(0, 1)). Drop through by briefly disabling the player's mask bit or raising the position.
  • CharacterBody2D defaults to MOTION_MODE_GROUNDED for platformers. Use MOTION_MODE_FLOATING for top-down.
  • Coyote time, jump buffering and variable jump height are in the reference.

Many objects

Thousands of bullets or particles: MultiMeshInstance2D or GPU particles, or skip nodes entirely with RenderingServer canvas items and PhysicsServer2D. VisibleOnScreenEnabler2D pauses off-screen enemies. See godot-performance.

Patterns (platformer feel, top-down movement, camera shake, tile queries, custom draw), compiled by the tests: references/patterns.md

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.