You can also show on-screen notifications by
TCastleNotifications component. This is a
TUIControl descendant, so you just create it and
Window.Controls list, just like other
mentioned in previous chapters.
You can actually just use the global
Notifications instance created
for you in the CastleGameNotifications unit (just add it to
Window.Controls list). Some engine game features already make
notifications to it, and it is also automatically set up to cooperate
with CastleScript writeln() function, so you can print to it from VRML/X3D scripts.
// make sure you have these units on "uses" clause: uses ..., CastleGameNotifications, CastleColors, CastleRectangles; // use this at initialization: // (adjust anchors and colors to your taste) Notifications.TextAlignment := hpMiddle; Notifications.Anchor(hpMiddle); Notifications.Anchor(vpBottom, 5); Notifications.Color := Yellow; Window.Controls.Add(Notifications); // use this whenever you want to show a notification: Notifications.Show('You picked 10 ammo!');
But you're not forced to use global
CastleGameNotifications. You may as well create
You can ignore our
CastleGameNotifications, if you don't like the