Gamedev Framework (gf)  0.3.0
A C++11 framework for 2D games
Classes | Typedefs | Enumerations
Game classes

All the classes related to game systems and game entities. More...

Classes

class  gf::AssetManager
 An asset manager. More...
 
struct  gf::Penetration
 Data about the collision between two objects. More...
 
class  gf::Entity
 A game entity. More...
 
class  gf::EntityContainer
 A collection of entities. More...
 
struct  gf::Message
 The base class for all messages. More...
 
class  gf::MessageManager
 A message manager. More...
 
class  gf::Model
 A game object that can be updated. More...
 
class  gf::ModelContainer
 A collection of models. More...
 
class  gf::ResourceCache< T >
 A generic cache for resources. More...
 
class  gf::ResourceManager
 A resource manager. More...
 
class  gf::TextureAtlas
 A collection of sub-texture. More...
 

Typedefs

using gf::MessageHandler = std::function< MessageStatus(Id, Message *)>
 A message handler. More...
 
using gf::MessageHandlerId = uint64_t
 An identifier for a message handler. More...
 

Enumerations

enum  gf::MessageStatus {
  gf::MessageStatus::Keep,
  gf::MessageStatus::Die
}
 A message status. More...
 

Detailed Description

All the classes related to game systems and game entities.

Typedef Documentation

using gf::MessageHandler = typedef std::function<MessageStatus(Id, Message *)>

A message handler.

gf::MessageHandler is a function that can be called when a message is sent in a message handler. It can be a free function:

gf::MessageStatus onHeroPosition(gf::Id type, gf::Message *msg) {
assert(type == HeroPosition::type);
auto heroPosition = static_cast<HeroPosition*>(msg);
// do something with heroPosition->position ...
}
// ...
gf::MessageHandler handler = onHeroPosition;

It can also be a member function (which is, in fact, the most probable use case).

struct Foo {
gf::MessageStatus onHeroPosition(gf::Id type, gf::Message *msg) {
assert(type == HeroPosition::type);
auto heroPosition = static_cast<HeroPosition*>(msg);
// do something with heroPosition->position ...
}
};
// ...
Foo foo;
gf::MessageHandler handler = std::bind(&Foo::onHeroPosition, &foo);
See also
gf::MessageManager, gf::Message, gf::Id
using gf::MessageHandlerId = typedef uint64_t

An identifier for a message handler.

See also
gf::MessageHandler

Enumeration Type Documentation

enum gf::MessageStatus
strong

A message status.

gf::MessageStatus indicates if a handler should be kept by the message manager or can be removed so that it will not receive any more messages.

See also
gf::MessageManager, gf::MessageHandler
Enumerator
Keep 

The handler must be kept

Die 

The handler can be removed