Typography
Typography is almost the same as a template
except it deals exclusively with text elements. It has an extra implicit parameter called text
which is the string of text it represents and makes the $text
built in available. Unlike a template
, typography
cannot declare a render
block or
slots.
// This is a trival typography with no extra behavior or style
// Declaring typography like this is useful to define a consistent
// set of text based elements for your game.
typography Label;
// a more complex typography declaration can include parameters, state, behavior etc.
typography ComplexLabel : CompanionType {
required bool isBold;
state int clickCount;
style = [@some-style];
attr:bold = isBold;
mouse:click => clickCount++;
// $text provides an interface for getting/setting/manipulating the underlying text string
before:update => $text.SetText($"Clicked {clickCount} times");
}
// typography can also accept generics
typography GenericLabel<T> {
required T value;
before:update => $text.SetText(value.ToString());
}