cocos2d-x-3.3rc2 动作管理 ActionManager
来源:互联网 发布:印度对中国的看法 知乎 编辑:程序博客网 时间:2024/05/22 04:28
创建一个精灵 并指定动作 但动作并不执行
auto grossini = Sprite::create(s_pathGrossini); addChild(grossini, 0, kTagGrossini); grossini->setPosition(VisibleRect::center() ); auto action = MoveBy::create(1, Vec2(150,0)); auto director = Director::getInstance(); director->getActionManager()->addAction(action, grossini, true); schedule( CC_SCHEDULE_SELECTOR(PauseTest::unpause), 3); // 3秒后执行动作
通过导演下的动作管理可以恢复执行动作
void PauseTest::unpause(float dt){ unschedule( CC_SCHEDULE_SELECTOR(PauseTest::unpause) ); auto node = getChildByTag( kTagGrossini ); auto director = Director::getInstance(); director->getActionManager()->resumeTarget(node);}
不同的动作可以指定相同的tag
pRepeatMove->setTag(kTagSequence);
pRepeatScale->setTag(kTagSequence);
通过tag 停止所有此tag的动作。
sprite->stopAllActionsByTag(kTagSequence);
ActionManager 类
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'. */ void addAction(Action *action, Node *target, bool paused);<p> //action 动作 //target 精灵 //paused 是否暂停</p> /** 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. */ void removeAllActionsFromTarget(Node *target); /** Removes an action given an action reference. */ void removeAction(Action *action); /** Removes an action given its tag and the target */ void removeActionByTag(int tag, Node *target); /** Removes all actions given its tag and the target */ void removeAllActionsByTag(int tag, Node *target); /** Gets an action given its tag an a 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. */ 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. */ void pauseTarget(Node *target); /** Resumes the target. All queued actions will be resumed. */ void resumeTarget(Node *target); ////恢复执行指定节点的动作 /** Pauses all running actions, returning a list of targets whose actions were paused. */ Vector<Node*> pauseAllRunningActions(); /** Resume a set of targets (convenience function to reverse a pauseAllRunningActions call) */ void resumeTargets(const Vector<Node*>& targetsToResume); 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;};
0 0
- cocos2d-x-3.3rc2 动作管理 ActionManager
- 3.X:ActionManager动作管理类浅析:
- Cocos2d-x 3.4 Action管理(ActionManager)总结
- cocos2dx ActionManager动作管理
- cocos2d-x 3.1 ActionManager
- Cocos2d-x-----------------------------------------------ActionManager
- cocos2d-x-3.3rc2 字体
- cocos2d-x-3.3rc2 定时器
- cocos2D-x:动作管理(5)
- cocos2d-x-3.3rc2-001-hello-world
- cocos2d-x-3.3rc2 testcpp 触摸事件
- cocos2d-x-3.3rc2 其他事件
- cocos2d-x-3.3rc2 通知中心
- cocos2d-x-3.3rc2 输入框
- Cocos2d-X官方Demo---1.ActionManager
- cocos2d-x3.3 源码分析之-动作Action和ActionManager
- cocos2d-x-3.3rc2-005 cocos中的智能指针
- cocos2d-x-3.3rc2 坐标转换和锚点
- 有关spring的依赖注入和@resource注解的使用
- 透彻分析反射的基础_Class类
- web项目转化成maven项目步骤
- iOS - UIButton(UIEdgeInsets) 设置button上的文字和图片
- Android中Context详解——你所不知道的Context
- cocos2d-x-3.3rc2 动作管理 ActionManager
- Asp.net MVC中的ViewData与ViewBag
- 关注上帝的所想所爱,创造无限财富
- 如何用英文说明一种方法的优缺点(优点和缺点)
- POJ 1125 Floyd
- 使用Eclipse Memory Analyzer进行内存泄漏分析三部曲
- NSObject的常见方法
- RecyccleView 详解
- 肉鸡美眉跨平台DDoS组织