CCActionManager:
思维导图:
源码:
/** @class ActionManager
@brief ActionManager is a singleton that manages all the actions.
Normally you won't need to use this singleton directly. 99% of the cases you will use the Node interface,
which uses this singleton.
But there are some cases where you might need to use this singleton.
Examples:
- When you want to run an action where the target is different from a Node.
- When you want to pause / resume the actions.
@since v0.8
*/
/// ActionManager是一个管理所有动作的单例
/// 正常情况下你没必要直接使用这个单例。99%的情况下你将使用Node的接口
/// 但是有一些情况你可能会用到这个单例:
/// 1.当你想运行一个target是一个不同的Node的时候
/// 2.当你想暂停/恢复动作的时候
class CC_DLL ActionManager : public Ref
{
public:
/**
* @js ctor
*/
ActionManager(void);
/**
* @js NA
* @lua NA
*/
~ActionManager(void);
// actions
/** Adds an action with a target.
If the target is already present, then the action will be added to the existing target.
If the target is not present, a new instance of this target will be created either paused or not, and the action will be added to the newly created target.
When the target is paused, the queued actions won't be 'ticked'.
*
* @param action A certain action.
* @param target The target which need to be added an action.
* @param paused Is the target paused or not.
*/
/// 添加一个动作,传入动作的target
/// 如果这个target已经存在,那么这个动作就会被添加到现存的target中
/// 如果这个target不存在,target的一个新的接口将被创建,这个动作将会添加到新的target中
/// 当这个target暂停的时候,动作的队列不会改变
void addAction(Action *action, Node *target, bool paused);
/** Removes all actions from all the targets.
*/
/// 移除所有的动作
void removeAllActions();
/** Removes all actions from a certain target.
All the actions that belongs to the target will be removed.
*
* @param target A certain target.
*/
/// 移除一个确定的taget的所有动作
void removeAllActionsFromTarget(Node *target);
/** Removes an action given an action reference.
*
* @param action A certain target.
*/
/// 移除一个当前的动作
void removeAction(Action *action);
/** Removes an action given its tag and the target.
*
* @param tag The action's tag.
* @param target A certain target.
*/
/// 根据标签移除动作
void removeActionByTag(int tag, Node *target);
/** Removes all actions given its tag and the target.
*
* @param tag The actions' tag.
* @param target A certain target.
* @js NA
*/
/// 根据标签移除所有是这个标签的动作
void removeAllActionsByTag(int tag, Node *target);
/** Gets an action given its tag an a target.
*
* @param tag The action's tag.
* @param target A certain target.
* @return The Action the with the given tag.
*/
/// 根据标签得到相应的动作
Action* getActionByTag(int tag, const Node *target) const;
/** Returns the numbers of actions that are running in a certain target.
* Composable actions are counted as 1 action. Example:
* - If you are running 1 Sequence of 7 actions, it will return 1.
* - If you are running 7 Sequences of 2 actions, it will return 7.
*
* @param target A certain target.
* @return The numbers of actions that are running in a certain target.
* @js NA
*/
/// 得到一个target中当前运行的动作
ssize_t getNumberOfRunningActionsInTarget(const Node *target) const;
/** @deprecated Use getNumberOfRunningActionsInTarget() instead.
*/
CC_DEPRECATED_ATTRIBUTE inline ssize_t numberOfRunningActionsInTarget(Node *target) const { return getNumberOfRunningActionsInTarget(target); }
/** Pauses the target: all running actions and newly added actions will be paused.
*
* @param target A certain target.
*/
/// 根据target暂停其动作
void pauseTarget(Node *target);
/** Resumes the target. All queued actions will be resumed.
*
* @param target A certain target.
*/
/// 根据target恢复其动作
void resumeTarget(Node *target);
/** Pauses all running actions, returning a list of targets whose actions were paused.
*
* @return A list of targets whose actions were paused.
*/
/// 暂停所有正在运行的动作
Vector<Node*> pauseAllRunningActions();
/** Resume a set of targets (convenience function to reverse a pauseAllRunningActions call).
*
* @param targetsToResume A set of targets need to be resumed.
*/
/// 恢复target数组中所有target的动作
void resumeTargets(const Vector<Node*>& targetsToResume);
/** Main loop of ActionManager.
* @param dt In seconds.
*/
/// 更新
void update(float dt);
protected:
// declared in ActionManager.m
void removeActionAtIndex(ssize_t index, struct _hashElement *element);
void deleteHashElement(struct _hashElement *element);
void actionAllocWithHashElement(struct _hashElement *element);
protected:
struct _hashElement *_targets;
struct _hashElement *_currentTarget;
bool _currentTargetSalvaged;
};
// end of actions group
/// @}
CCActionPageTurn3D:
思维导图:
源码:
/**
@brief This action simulates a page turn from the bottom right hand corner of the screen.
@details It's not much use by itself but is used by the PageTurnTransition.
Based on an original paper by L Hong et al.
http://www.parc.com/publication/1638/turning-pages-of-3d-electronic-books.html
@since v0.8.2
*/
/// 这个动作模仿了一个从屏幕的右下角翻页的动作
class CC_DLL PageTurn3D : public Grid3DAction
{
public:
/**
* @js NA
*/
/// 返回网格基类
virtual GridBase* getGrid() override;
/**
@brief Create an action with duration, grid size.
@param duration Specify the duration of the PageTurn3D action. It's a value in seconds.
@param gridSize Specify the size of the grid.
@return If the creation sucess, return a pointer of PageTurn3D action; otherwise, return nil.
*/
/// 创建一个翻页动作
static PageTurn3D* create(float duration, const Size& gridSize);
// Overrides
virtual PageTurn3D* clone() const override;
virtual void update(float time) override;
};