monogame-2d
Installation
SKILL.md
MonoGame 2D Rendering Implementation Guide
This skill provides architecture rules and implementation patterns for MonoGame 2D graphics. Apply the rules below directly when writing rendering code. For detailed API signatures and code samples, read references/2d.md.
SpriteBatch Fundamentals
SpriteBatch is the primary 2D rendering API. Every Begin()/End() pair flushes a draw batch to the GPU — minimize how many pairs you use per frame.
Choosing a Sort Mode
| Mode | When to use |
|---|---|
Deferred (default) |
General sprite rendering; buffers all calls, sorts by texture at End() |
BackToFront |
Overlapping sprites with explicit depth; uses layerDepth parameter |
FrontToBack |
Same as above, reversed |
Texture |
Many sprites from multiple atlases; groups by texture to reduce state changes |
Immediate |
Per-sprite Effect parameter changes; sends each draw to GPU instantly — avoid unless needed |