-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
I meant to add this code snippet here a while ago but was reminded with the recent issue Keepsie brought up in the Discord.
I will update the examples soon but I just want to document it here in case people wonder how to add SpriteSheet buttons to their UI.
public class TestUI : StartupScript
{
private SpriteSheet _uiSpriteSheet;
private SpriteFromSheet _buttonPressed;
private SpriteFromSheet _buttonNotPressed;
private SpriteFromSheet _buttonHover;
public override void Start()
{
var buttonSheet = Content.Load<SpriteSheet>("StrideUIDesigns");
_buttonNotPressed = new()
{
Sheet = _uiSpriteSheet,
CurrentFrame = 1,
};
_buttonHover = new()
{
Sheet = _uiSpriteSheet,
CurrentFrame = 0,
};
_buttonPressed = new()
{
Sheet = _uiSpriteSheet,
CurrentFrame = 2,
};
}
private void CreateButton()
{
var button = new Button
{
MouseOverImage = _buttonHover,
PressedImage = _buttonPressed,
NotPressedImage = _buttonNotPressed,
};
}
}
VaclavElias
Metadata
Metadata
Assignees
Labels
No labels