This page explains how Gamma uses gma.renderHelper to provide the link between Gamma entities and the rendering engine.
Everything that is rendered in Gamma is found inside the entities or levelExtras property of the current level. The content of the entities list doesn’t matter, as long as each entity has a helper property that is an instance of gma.renderHelper, and that the render helper has a template property set to a descendant of gma.baseTemplate. These render helpers are used to provide the visual representation to the scene helper.
See Appearance for more information on templates
These render helper objects are responsible for ensuring that the visual representation of the entity it belongs to has the correct size and position and is added to the current sceneHelper. The render helper also maintains a cache of the object specifying this representation.
As part of the Game Loop, the manager’s sceneHelper is asked to render the scene using it’s render method. This method will first update all the objects specific to the rendering engine using setRenderedLocations and then use ask the rendering engine to render everything.
The setRenderedLocations method will go through each entity on the current level and call setLocation on each entity’s render helper. This method will get the object that represents the entity and make sure it accurately represents the size and position of the entity.
To get the rendering specific object from a render helper, we call it’s getRenderedObj method. This method will look for an _instance attribute on the render helper. If it does not have one, then it will ask it’s template (one is added as part of prepareEntity) to give it an instance to work with by calling it’s getInstance method.
You can override the template on the render helper just by setting it’s _instance property.