Panel Sprite ("9 patch")
A Panel Sprite object is a versatile image element that is divided into nine separate segments or slices. Each slice can be scaled independently, ensuring that the object maintains its proportions even when resized. This feature makes Panel Sprites ideal for creating:
- Menu frames: Consistent borders for menu elements
- Tiles: Land, water, and other terrain types in top-down games
- Platforms: In platformer games
- Health bars: Dynamic indicators for health or resource levels
Note: Panel Sprite objects do not support points, custom hitboxes, or animations.
How It Works
The Panel Sprite's image is divided into nine segments, as illustrated below:
- Segments 1, 3, 7, and 9 remain unchanged and are not scaled.
- Segments 2 and 8 are scaled horizontally only.
- Segments 4 and 6 are scaled vertically only.
- Segment 5 is scaled both horizontally and vertically.
Scaling Behavior
Unlike regular sprites that are scaled uniformly, Panel Sprites maintain their image quality by scaling each segment individually. This preserves the object's proportions and prevents distortion.
Using a Panel Sprite
- Create a New Object: Select "Panel Sprite" from the Objects panel.
- Set Margins: Define the size of the margins (top, left, right, bottom) that separate the segments. These margins should represent the center portion of your image.
- Adjust Scaling: Toggle whether the borders and center segments stretch or repeat when the object is scaled.
Scaling Behavior
If "repeat borders and center texture" is enabled, segments 2, 4, 5, 6, 8 will be repeated instead of stretched. This will scale the object in a way that's similar to the tiled sprite object.
By understanding the Panel Sprite's unique scaling behavior and customizing its margins, you can effectively use this object to create dynamic and visually appealing elements in your game.
Tutorial
- Youtube Video
soon!
- Example
soon!