App
Each scar application should define a main class which inherits from Scar::App
. This abstract class contains the basic structure of a scar app and takes care of running all the features of the library such as events, tweens, actions and so on.
You have to define three methods: init
, update(dt)
and render(dt)
. In init
all the applications' initialization should take place (like loading assets). update
and render
are intended for game logic updates and drawing. The class is then created with a SFML window and an Input manager instance (why will be explained in Input Handling)
The init
and update
functions should not update or draw any entities. They are supposed to be an easy way to update global game status or to debug. Drawing is explained in a later section.
At the bottom of the example you can see how a scar app is executed. You just have to create a window and an input manager and pass them to his app class. To start the app, simply call the App#run
method.
More stuff
The Scar::App
class defines getters for the sfml window window
, the input handler input
, the scene stack scene_stack
and the current actions actions
. Refer to the reference for more info.
It also provides the App#exit
instance method which can be used to exit the program. It unloads all assets and disposes the window before exiting with the given status code.
How events, scenes, tweens and actions are handled is be explained in the respective sections of this book.
Last updated