Angel 3.2
A 2D Game Prototyping Engine
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Renderable Class Reference

Our base simulation element that gets inserted to the World. More...

#include <Renderable.h>

+ Inheritance diagram for Renderable:

Public Member Functions

 Renderable ()
virtual ~Renderable ()
virtual void Update (float dt)
virtual void Render ()
void Destroy ()
bool IsDestroyed ()
int GetLayer ()

Protected Member Functions

virtual void PreDestroy ()

Protected Attributes

bool _deleteMe
int _layer


class World

Detailed Description

This is the base class from which most of the simulation elements in Angel derive. When you insert a Renderable into the World, it will receive Update and Render calls once per frame.

Definition at line 38 of file Renderable.h.

Constructor & Destructor Documentation

Renderable::Renderable ( )

The base constructor just sets a flag on the Renderable to not delete it, since that would be kind of a buzzkill out of the gate.


Definition at line 49 of file Renderable.h.

virtual Renderable::~Renderable ( )

Abstract base class needs a virtual destructor.

Definition at line 54 of file Renderable.h.

Member Function Documentation

virtual void Renderable::Update ( float  dt)

This function gets called once per frame. Any game logic for an Actor should be done in this function, since it provides you with a dt for controlling rate of movement, animation, etc.

dtThe amount of time (in seconds) that has elapsed since the last frame.

Reimplemented in Actor, GridActor, Camera, GameManager, ParticleActor, MobileSimulator, and Sentient.

Definition at line 64 of file Renderable.h.

virtual void Renderable::Render ( )

This function also gets called once per frame, after the Renderable::Update call. Anything you do in this function should be strictly related to drawing something on the screen. Moving it, changing its appearance/properties/etc. should happen in Update.

Reimplemented in Actor, GridActor, Camera, TextActor, ParticleActor, GameManager, HUDActor, and Sentient.

Definition at line 72 of file Renderable.h.

void Renderable::Destroy ( )

A safe way to kill off a Renderable – it will be removed from the world and deleted from memory at the end of the current Update loop.

The protected Renderable::PreDestroy function is guaranteed to be called exactly once by this function, even if you call it many times.

Definition at line 81 of file Renderable.h.

bool Renderable::IsDestroyed ( )

Used by the World to see if a Renderable is flagged to be deleted.

True if the Renderable should be removed and deleted.

Definition at line 94 of file Renderable.h.

int Renderable::GetLayer ( )

The layer to which this Renderable has been assigned in the world. returns garbage if it hasn't been added to the World yet. (Negative layers are valid.)

The world layer for this Renderable

Definition at line 103 of file Renderable.h.

virtual void Renderable::PreDestroy ( )

Will get called before this Renderable is destroyed (if you do it via the Destroy function, obviously). Override this function in a subclass to do any cleanup work that is appropriate to your element.

Definition at line 110 of file Renderable.h.

The documentation for this class was generated from the following file: