Adding Sprites - EverestAPI/Resources GitHub Wiki

This is a tutorial for adding static or dynamic sprites to the game that can then be accessed from your code mod.
For questions and feedback, please contact @coloursofnoise on the Celeste Discord 🔗.

Table of Contents:

Understanding the Atlas system

Adding custom sprites to your code mod:

The Atlas System

Atlases

Celeste stores its textures in Atlases, with each atlas being used for different aspects of the game.

Celeste's textures were packed using Crunch 🔗 using the binary format, resulting in the .meta and .data files in the Contents folder. These graphics have been extracted here 🔗 in a process that preserved the original folder structure and may be freely used for Celeste modding.

To load a texture into a preexisting atlas, follow the directions here relating to pre-supported content mappings.

Atlases that are shipped and loaded by the vanilla game include:

  • Gameplay - for ingame textures
  • Gui - for menus and title screens
  • Portraits - for character dialogue

When the game is loaded, it takes every file present in each atlas’ folder, and adds them to an Atlas object. They can then be referenced later by querying the atlas using the relative path of the file within the file structure.

SpriteBanks

SpriteBanks are an extension of the Atlas system that incorporates an xml structure to compile multiple textures into animations, or Sprites.

Vanilla SpriteBanks include:

  • Sprites.xml - for gameplay sprites
  • SpritesGui.xml - for hires menu and title screens
  • Portraits.xml - for character dialogue

Custom Sprites for Code Mods

Using MTextures in Code

This is the simplest way to load a new texture into the game, however it is only really useful for static images.

To retrieve a texture and assign it to a variable, simply access the Atlas as you would an dictionary, using a string containing the relative path excluding file extensions of your image as the index.
Ex: MTexture myTexture = GFX.Game["pathname"]; for a texture in the Gameplay atlas.

To display your texture in game, call the Draw or DrawCentered method of your texture in the appropriate Render method.
Ex: myTexture.Draw(position);

An Image component can also be added to an entity to render an MTexture relative to the entity during the base.Render() call.
Ex: Add(new Image(myTexture));

Using a SpriteBank File

Spritebank files are xml files that group textures into sprites with animations and states. They cannot be modified dynamically.

Most of the vanilla Gameplay sprites are stored in the Sprites.xml file in the Graphics folder for Celeste. To add your own sprites, you will need to make a similar file in your own mod folder, also in a Graphics subfolder.

A Spritebank file can also be created elsewhere within your mod, but it must be loaded separately by creating a new SpriteBank targeting the appropriate Atlas.

Adding your own sprite to this file will loosely emulate the following example:

<spriteName path="sprite/folder" start="initialanimation">
  <!-- If you want it centered: -->
  <Center/>

  <!-- This animation will loop until changed: -->
  <Loop id="loopID" path="texturename" delay="0.15"/>

  <!-- This animation will play once: -->
  <Anim id="animID" path="othertexturename" delay="0.08" frames="3,7-9"/>
</spriteName>

In the above example, your file structure would look something like this:

Graphics/Atlases/Gameplay
  ↳ sprite
    ↳ folder
      ↳ texturename0
      ↳ texturename1
      ↳ texturename2
      ↳ othertexturename3
      ↳ othertexturename7
      ↳ othertexturename8
      ↳ othertexturename9

Your sprite can then be retrieved from the SpriteBank with code similar to the following:

Sprite mySprite = GFX.SpriteBank.Create("spriteName");
Add(mySprite); // Add the sprite Component to your entity
mySprite.Play("animID") // Play an animation

Note

If you have created your own SpriteBank separate from the main Gameplay sprites, replace GFX.SpriteBank with a reference to your SpriteBank.

Creating Sprites in Code

It is also possible to add and play custom animations without adding them to a SpriteBank file. This allows for animations to be created dynamically as the program runs.

This method uses the Atlas to retrieve the sprite, then allows for the addition of loops and animations within the code:

Sprite mySprite = new Sprite(GFX.Game, "sprite/folder/");
mySprite.AddLoop("loopID", "path", delayFloat); // Add an animation
mySprite.Play("loopID"); // Play that animation
⚠️ **GitHub.com Fallback** ⚠️