Interface for drawable objects.
More...
#include <Drawable.h>
Interface for drawable objects.
Definition at line 41 of file Drawable.h.
◆ Ptr
Unique object pointer.
Definition at line 42 of file Object.h.
◆ ~Drawable()
ime::Drawable::~Drawable |
( |
| ) |
|
|
override |
◆ draw()
virtual void ime::Drawable::draw |
( |
priv::RenderTarget & |
renderTarget | ) |
const |
|
pure virtual |
Draw object on a render target.
- Parameters
-
renderTarget | Target to draw object on |
- Note
- This function is intended for internal use only
Implemented in ime::Shape, ime::Sprite, and ime::Tile.
◆ emitChange()
void ime::Object::emitChange |
( |
const Property & |
property | ) |
|
|
protectedinherited |
Dispatch a property change event.
- Parameters
-
property | The property that changed |
This function will invoke all the event listeners of the specified property
- See also
- emit
◆ emitDestruction()
void ime::Object::emitDestruction |
( |
| ) |
|
|
protectedinherited |
Emit a destruction event.
- Note
- This function must be the first statement in the definition of a destructor to avoid undefined behavior. In addition, note that destruction listeners are invoked once. Therefore, multiple classes in a hierarchy may call this function but the class that makes the call first will be the one that invokes the destruction listeners
◆ getClassName()
virtual std::string ime::Object::getClassName |
( |
| ) |
const |
|
pure virtualinherited |
Get the name of the objects concrete class.
- Returns
- The name of the objects concrete class
This function is implemented by all internal classes that inherit from this class (either directly or indirectly). Example:
GameObject gObject;
Class for modelling game objects (players, enemies etc...)
An abstract top-level base class for IME objects.
virtual std::string getClassName() const =0
Get the name of the objects concrete class.
- See also
- getClassType
Implemented in ime::audio::Music, ime::audio::SoundEffect, ime::GameObject, ime::GridObject, ime::CyclicGridMover, ime::GridMover, ime::KeyboardGridMover, ime::RandomGridMover, ime::TargetGridMover, ime::AABB, ime::BoxCollider, ime::CircleCollider, ime::EdgeCollider, ime::PolygonCollider, ime::DistanceJoint, ime::RigidBody, ime::RenderLayer, ime::RenderLayerContainer, ime::Scene, ime::Camera, ime::CircleShape, ime::ConvexShape, ime::RectangleShape, ime::Sprite, ime::SpriteSheet, and ime::Tile.
◆ getClassType()
std::string ime::Drawable::getClassType |
( |
| ) |
const |
|
overridevirtual |
◆ getObjectId()
unsigned int ime::Object::getObjectId |
( |
| ) |
const |
|
inherited |
Get the unique id of the object.
- Returns
- The unique id of the object
Note that each instance of ime::Object has a unique id
- See also
- setTag
◆ getTag()
const std::string & ime::Object::getTag |
( |
| ) |
const |
|
inherited |
Get the tag assigned to the object.
- Returns
- The tag of the object
- See also
- setTag
◆ isEventListenerSuspended()
bool ime::Object::isEventListenerSuspended |
( |
int |
id | ) |
const |
|
inherited |
Check if an event listener is suspended or not.
- Parameters
-
id | The identification number of the listener to be checked |
- Returns
- True if suspended, otherwise false
This function also returns false if the specified event listener does not exist
- See also
- suspendedEventListener
◆ isSameObjectAs()
bool ime::Object::isSameObjectAs |
( |
const Object & |
other | ) |
const |
|
inherited |
Check if another object is the same instance as this object.
- Parameters
-
other | The object to compare against this object |
- Returns
- True if other is the same instance as this object, otherwise false
◆ onDestruction()
int ime::Object::onDestruction |
( |
const Callback<> & |
callback | ) |
|
|
inherited |
Add a destruction listener.
- Parameters
-
callback | Function to be executed when the object is destroyed |
- Returns
- The unique id of the destruction listener
The destruction listener is called when the object reaches the end of its lifetime. Note that an object may have multiple destruction listeners registered to it
- Warning
- It's not advised to call virtual functions in the destruction callback as some parts of the object may have already been destroyed by the time the callback is invoked. In such an event, the behavior is undefined
- See also
- removeEventListener
◆ onPropertyChange() [1/2]
int ime::Object::onPropertyChange |
( |
const Callback< Property > & |
callback, |
|
|
bool |
oneTime = false |
|
) |
| |
|
inherited |
Add an event listener to any property change event.
- Parameters
-
callback | The function to be executed when any property changes |
oneTime | True to execute the callback one-time or false to execute it every time the event is triggered |
- Returns
- The unique id of the event listener
When unsubscribing the any property change event handler, you must pass "propertyChange" as the name of the event
- See also
- onPropertyChange(const std::string&, const ime::Callback<ime::Property>&)
◆ onPropertyChange() [2/2]
int ime::Object::onPropertyChange |
( |
const std::string & |
property, |
|
|
const Callback< Property > & |
callback, |
|
|
bool |
oneTime = false |
|
) |
| |
|
inherited |
Add an event listener to a specific property change event.
- Parameters
-
property | The name of the property to add an event listener to |
oneTime | True to execute the callback one-time or false to execute it every time the event is triggered |
callback | The function to be executed when the property changes |
- Returns
- The unique id of the event listener
A property change event is triggered by any function that begins with set, where the the text after set is the name of the property. For example, the setTag() function, modifies the tag property of the object, thus will generate a "tag" change event each time it is called
Note that multiple event listeners may be registered to the same property change event. In addition, when adding a property change event listener, the name of the property must be in lowercase.
player.onPropertyChange("tag", [](const Property& property) {
cout << "New tag: " << property.getValue<std::string>() << endl;
});
...
player.setTag("player1");
- See also
- unsubscribe and onPropertyChange(const ime::Callback<ime::Property>&)
◆ removeEventListener() [1/2]
bool ime::Object::removeEventListener |
( |
const std::string & |
event, |
|
|
int |
id |
|
) |
| |
|
inherited |
Remove an event listener from an event.
- Parameters
-
event | The name of the event to remove an event listener from |
id | The unique id of the event listener to be removed |
- Returns
- True if the event listener was removed or false if the event or the event listener is does not exist
auto tagChangeId =
object.onPropertyChange(
"tag", [](
ime::Property tag) {
std::cout << name.getValue<std::string>() << std::endl;
});
object.removeEventListener("tag", tagChangeId);
Class that can store a value of any type.
◆ removeEventListener() [2/2]
bool ime::Object::removeEventListener |
( |
int |
id | ) |
|
|
inherited |
Remove an event listener.
- Parameters
-
id | The id of the event listener to be removed |
- Returns
- True if the event listener was removed or false if no such handler exists
◆ setTag()
void ime::Object::setTag |
( |
const std::string & |
tag | ) |
|
|
inherited |
Assign the object an alias.
- Parameters
-
tag | The alias of the object |
This function is useful if you want to refer to the object by a tag instead of its object id. Unlike an object id, multiple objects may have the same tag
By default, the tag is an empty string
- See also
- getObjectId
◆ suspendedEventListener()
void ime::Object::suspendedEventListener |
( |
int |
id, |
|
|
bool |
suspend |
|
) |
| |
|
inherited |
Pause or resume execution of an event listener.
- Parameters
-
id | The event listeners unique identification number |
suspend | True to suspend/pause or false to unsuspend/resume |
- See also
- isEventListenerSuspended
◆ eventEmitter_
The documentation for this class was generated from the following file: