class EE::Scene::Action¶
Overview¶
#include <action.hpp> class Action { public: // typedefs typedef std::function<void(Action*, const ActionType&)> ActionCallback; typedef Uint64 UniqueID; // enums enum ActionType; // construction virtual ~Action(); // methods virtual void start() = 0; virtual void stop() = 0; virtual void update(const Time& time) = 0; virtual bool isDone() = 0; virtual Float getCurrentProgress() = 0; virtual Time getTotalTime() = 0; virtual Action* clone() const; virtual Action* reverse() const; Uint32 getFlags() const; void setFlags(const Uint32& flags); UniqueID getTag() const; void setTag(const UniqueID& tag); Node* getTarget() const; Uint32 addEventListener(const ActionType& actionType, const ActionCallback& callback); Action* on(const ActionType& actionType, const ActionCallback& callback); void removeEventListener(const Uint32& callbackId); void sendEvent(const ActionType& actionType); void setTarget(Node* target); void setId(const Action::UniqueID& id); const Action::UniqueID& getId(); };
Detailed Documentation¶
Methods¶
virtual void start() = 0
Starts the action.
virtual void stop() = 0
Stops the actions (pause it, it will not reset the animation state).
virtual void update(const Time& time) = 0
Update the action state (shouldn’t be called manually unless you actually now what you are doing)
virtual bool isDone() = 0
Returns:
If the action is completed.
virtual Float getCurrentProgress() = 0
Returns:
The current progress percentage. Normalized between 0 and 1.
virtual Time getTotalTime() = 0
The total action time.
virtual Action* clone() const
Clones the action.
virtual Action* reverse() const
Clones and reverse the action sequence. Note: not all actions can be reversed.
Uint32 getFlags() const
Returns:
The action custom flags.
void setFlags(const Uint32& flags)
Sets the action custom flags.
UniqueID getTag() const
Returns:
The action tag.
void setTag(const UniqueID& tag)
Sets a tag to identify and filter actions.
Node* getTarget() const
The target node that the action is being applied.
Uint32 addEventListener(const ActionType& actionType, const ActionCallback& callback)
Adds an event listener for a specific Action::ActionType.
Parameters:
actionType |
The action type to receive the event notification. |
callback |
The callback to receive the event notification. |
Returns:
An unique event callback ID. This can be use to remove the event listener with Action::removeEventListener.
Action* on(const ActionType& actionType, const ActionCallback& callback)
Same as Action::addEventListener
void removeEventListener(const Uint32& callbackId)
Removes an event listener previusly added.
Parameters:
callbackId |
The ID of the event listener returned by the Action::addEventListener call. |
void sendEvent(const ActionType& actionType)
Manually emmit an event of type Action::ActionType.
void setTarget(Node* target)
Sets the action EE::Scene::Node target.
void setId(const Action::UniqueID& id)
Sets a unique ID to identify the action.
const Action::UniqueID& getId()
Returns:
The unique action ID.