Object2D Class Reference

#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 ()
 
- Functions inherited from Component
std::string GetTag ()
 
EntityGetHost () 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

- Public Types inherited from Component
using EventHandler = bool(*)(void *, Component *component, Entity::ID self, Entity::ID source, const std::vector< std::string > &args)
 
- Protected Member Functions inherited from Component
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

void OnAttach ( )
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
factorThe velocity amount to add. Can be negative.
directionThe direction to apply the velocity in degrees.
void SetVelocity ( double  factor,
double  direction 
)

Sets the velocity vector of an object.

Parameters
factorThe velocity to set.
directionThe direction to set the velocity in degrees.
void SetFrictionX ( double  amt)

Sets the amount of resistance to speed measured as a percentile.

Every frame, only the amount percent of the host Entity's velocity is retained. For example, if amt is specified to be .95, every frame 5% of the Entity's speed will be lost. This is applied in the horizontal direction.

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.

std::string GetInfo ( )
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