41 #ifndef __CU_ACTION_MANAGER_H__
42 #define __CU_ACTION_MANAGER_H__
46 #include <unordered_map>
47 #include <unordered_set>
64 #pragma mark ActionInstance
76 class ActionInstance {
79 std::shared_ptr<Node> target;
82 std::shared_ptr<Action> action;
85 std::function<float(
float)> interpolant;
106 ActionInstance() : state(0), duration(0.0f), elapsed(0.0f), paused(
false) {}
117 std::unordered_map<Node*, std::unordered_set<std::string>>
_keys;
120 std::unordered_map<std::string, ActionInstance*>
_actions;
124 #pragma mark Constructors
153 #pragma mark Static Constructors
159 static std::shared_ptr<ActionManager>
alloc() {
160 std::shared_ptr<ActionManager> result = std::make_shared<ActionManager>();
161 return (result->init() ? result :
nullptr);
165 #pragma mark Action Management
173 bool isActive(std::string key)
const;
187 const std::shared_ptr<Action>& action,
188 const std::shared_ptr<Node>& target) {
189 return activate(key,action,target,
nullptr);
210 const std::shared_ptr<Action>& action,
211 const std::shared_ptr<Node>& target,
212 std::function<
float(
float)> easing);
227 bool remove(std::string key);
262 void pause(std::string key);
275 #pragma mark Node Management
315 std::vector<std::string>
getAllActions(
const std::shared_ptr<Node>& target)
const;