Pieces allow you to group and reuse sets of elements that repeat throughout your project.
When should you create a Piece? #
It is best to create a piece when a set of elements with the same characteristics repeats frequently, making manual reconstruction tedious. Common examples:
- Repeated terrain areas.
- Animated elements, such as torches in a corridor.
- Complex reusable structures.
- UI components.
How are they used? #
Once created, a piece can be added to a scene just like:
- A sprite.
- An atlas region.
Pieces:
- Appear in the palette under the Pieces category.
- Can also be dragged directly from the Pieces list.
How do they impact exporting? #
Pieces can be exported independently to integrate them into custom workflows. However, in the most common scenario:
- If a piece is used within a scene, it does not need to be exported separately.
- When exporting the scene, a copy of the piece is included within it.
Important: If you modify a piece after using it in a scene, you must resave the scene and export it again. Changes to the reference piece will only reflect in the scene after this step.
Creating a Piece #
- In the top menu, go to Pieces → Create Piece.
- In the left panel, locate the newly created piece.
- Right-click on it and select Load.
Editing a Piece #
Once the piece is loaded, you can:
- Drag elements onto the canvas.
- Build the necessary composition.
Key differences from Scenes:
- Pieces do not have layers.
- Hierarchy is managed through element nesting.
To nest elements:
- Drag one element over another in the right panel.
- They will group automatically.
- When nested, the rotation points of the parent element affect the transformation of its children, similar to a skeletal/bone system.
Physics Properties in Pieces #
Elements within a piece can have physics properties. To configure them:
- Select an element.
- Define the physics shape type.
- Edit its values in the Properties panel.
Saving a Piece #
To save a piece:
- Go to the top menu: Pieces → Save Piece.
Usage via Code #
If you want to use a piece directly from your code, you can export it independently. If you only use it as part of a scene, simply load the scene and drag the pieces from the palette or list.