View RSS Feed

Cooler

What's new in the Apus Game Engine: April 2022.

Rate this Entry

MessageScene


Are you familiar with application.MessageBox() or ShowMessage()? I found that in every game I have to implement similar functions to show a message or confirm something. Now it is built into the engine: use TGameApplication.ShowMessage/Ask/Confirm to show a message dialog.

Font inheritance


In past few UI widgets has their own font property: Button, Label, EditBox, ListBox, so each element must be configured separately. Now "font" property belongs to the root TUIElement class, so all widgets have it (even those that don't display text). Font is inheritable: you can just set a font for the root UI element and all the children widgets will use it unless they have their own value.

Class attributes


Sometimes we need to assign a value to a class, for example: set a default value for each type of widget. A class variable is not suitable for this, because it is essentially a global variable - the same for the entire class hierarchy. So please welcome: class attributes!
For any object derived from TObjectEx you can use SetClassAttribute() to assign an inheritable value for this particular class only, which you can access via GetClassAttribute(). Attribute value is variant, so don't bother about types :-)
A new structure - TVarHash was added to implement this, so you can use it wherever you need a case-insensitive string->variant hash. BTW, there are many other useful and fast structures implemented in the Apus.Structs unit, so check them out!

SceneSwitcher


Usually all scene transitions in a game are made using scene effects: this handles properly scene Z-order, embeded UI etc - many complicated and important things. But this leads to the fact that similar lines of code are scattered across all units: TShowWindowEffect.Create(...effect parameters...). And all these units depend on SceneEffects unit.
Now it's all in the past! Use just game.SwitchToScene/ShowWindowedScene methods and the global SceneSwitcher interface will create the transition effects for you. Replace the scene switcher with your implementation to customize effects in the whole game (instead of editing many code lines scattered among the project). BTW, you can even use events to call the scene switcher, so, for example, to show a window upon button click you don't even need a click handler: Link('UI\ButtonName\Click', 'Engine\Cmd\ShowWindow\sceneName');

Scene: new methods


There are new scene methods to override:

  • Load() - this method is called from the control thread when game is launched: put any essential scene initialization here, and don't forget to either set loaded:=true or call inherited.
  • onShow() - called when scene status is set to Active (i.e. the scene become visible).
  • onHide() - called when scene status is changed from Active (i.e. the scene is no longer visible).


UI refactoring


In order to avoid oversized units and decrease the number of unit dependencies, the UI subsystem was refactored. Now most project units need just Apus.Engine.UI - the main "header" UI unit designed in the same manner like Apus.Engine.API, but just for the UI.

Submit "What's new in the Apus Game Engine: April 2022." to Digg Submit "What's new in the Apus Game Engine: April 2022." to del.icio.us Submit "What's new in the Apus Game Engine: April 2022." to StumbleUpon Submit "What's new in the Apus Game Engine: April 2022." to Google

Tags: engine, update Add / Edit Tags
Categories
Developer Diary

Comments