Skip to content
Franklin Webber edited this page Nov 26, 2012 · 2 revisions

Models

Overview

Models are stored in the 'models' directory. The template game that Metro generates provides you with a single hero model that is a subclass of Metro::Model that serves as a good examples. A model subclass defines a number of special methods, model properties, and events.

Methods

A model has a series of events which are essential to the lifetime of the model. These methods are defined as placeholder methods in the Model superclass. This allows you to redefine only the necessary methods in your model.

This method is executed immediately as the last step of initialize. As the Metro::Model does a lot of work for you with regarding to setting up content, it is best not to override initialize and instead define an after_initialize method within the subclasses of Model.

A model, however, is not yet visible and does not yet have the to draw, calculate layouts, or access any model object that requires the use of the window.

This method is called right after the model has been adopted by the scene.

This is often the method where you have access to all available resources. This is an ideal location for you to complete any initialize that requires relationships with each other, start playing music, or for models to generate or create any necessary sub-models.

This is called every update interval while the scene is being shown.

This is the method where you define any logic that needs to happen during the update interval of the scene.

This is called after every update and when the scene calls draw on all actors.

This is the method where you would define any drawing code that happens in your model.

Clone this wiki locally