Skip to content

Systems

John Tuttle edited this page Sep 30, 2017 · 2 revisions

Systems are where all of your game logic lives. They are added to the World object and can be run during either the update or draw loops of your game. Systems will be run in the order that they are added, though not that all of the :update systems will be run before moving on to the :draw systems.

When creating a system, you must provide it with a set of Components that acts like a fingerprint to match against the Entities in your game world. On each iteration of the game loop, the System will process every Entity that possesses the specified of Components.

Every System has an instance variable @world that is a reference to the World object. This reference can be used to retrieve the elapsed milliseconds since the last frame (if it is being set), the Blackboard hash used for passing global references around, and the Entity Manager should you need to do any custom Entity retrieval.