#include <Object2D.h>
Description
A component that gives movement and collision-detection related attributes to an Entity in 2D space.
Known events: "on-move" - called BEFORE applying the new position of the Entity. "on-collide" - source will always be what caused the collision
Functions | |
void | OnAttach () |
void | AddVelocity (double factor, double direction) |
void | SetVelocity (double factor, double direction) |
void | SetFrictionX (double amt) |
void | SetFrictionY (double amt) |
double | GetDirection () |
void | Halt () |
double | GetVelocityX () |
double | GetVelocityY () |
double | GetSpeed () |
void | SetSpeed (double) |
Dynacoe::Vector | GetNextPosition () |
std::string | GetInfo () |
![]() | |
std::string | GetTag () |
Entity * | GetHost () const |
template<typename T > | |
T * | GetHostAs () const |
Entity::ID | GetHostID () const |
bool | EmitEvent (const std::string &eventName, Entity::ID source=Entity::ID(), const std::vector< std::string > &args={}) |
bool | CanHandleEvent (const std::string &eventName) |
void | InstallHook (const std::string &eventName, EventHandler, void *data=nullptr) |
void | UninstallHook (const std::string &eventName, EventHandler) |
void | InstallHandler (const std::string &eventName, EventHandler, void *data=nullptr) |
void | UninstallHandler (const std::string &eventName, EventHandler) |
std::vector< std::string > | GetKnownEvents () const |
Additional Inherited Members | |
![]() | |
using | EventHandler = bool(*)(void *, Component *component, Entity::ID self, Entity::ID source, const std::vector< std::string > &args) |
![]() | |
virtual void | OnStep () |
virtual void | OnDraw () |
void | InstallEvent (const std::string &eventName, EventHandler mainHandler=nullptr, void *data=nullptr) |
void | UninstallEvent (const std::string &) |
Member Function Documentation
|
virtual |
Function that is called upon a host entity's Attach() function calling. It is run right after the host is set.
Reimplemented from Component.
void AddVelocity | ( | double | factor, |
double | direction | ||
) |
Compounds a velocity vector with the current velocity.
- Parameters
-
factor The velocity amount to add. Can be negative. direction The direction to apply the velocity in degrees.
void SetVelocity | ( | double | factor, |
double | direction | ||
) |
Sets the velocity vector of an object.
- Parameters
-
factor The velocity to set. direction The direction to set the velocity in degrees.
void SetFrictionX | ( | double | amt | ) |
void SetFrictionY | ( | double | amt | ) |
Same as SetFrictionX(), but in the vertical direction.
double GetDirection | ( | ) |
Returns the current direction that the entity is traveling in degrees.
void Halt | ( | ) |
Reduces the speed of the Entity to 0.
double GetVelocityX | ( | ) |
Returns the horizontal component of the current velocity.
double GetVelocityY | ( | ) |
Returns the vertical component of the current velocity.
double GetSpeed | ( | ) |
Returns the speed of the object.
void SetSpeed | ( | double | ) |
Sets the speed of the object in the current direction.
Dynacoe::Vector GetNextPosition | ( | ) |
Returns the position of the Entity after another frame of movement.
|
virtual |
Returns a string containing human-readable information on the state of the component.
Reimplemented from Component.
The documentation for this class was generated from the following file:
- /home/jc/git/Dynacoe/DynacoeSrc/includes/Dynacoe/Components/Object2D.h