CCComponentContainer,CCComponent解析
2015-08-26 23:27
701 查看
CCComponent:
源码:
CCComponentContainer:
源码:
源码:
enum { kComponentOnEnter, kComponentOnExit, kComponentOnUpdate }; /// 组件 class CC_DLL Component : public Ref { CC_CONSTRUCTOR_ACCESS: /** * @js ctor */ Component(void); public: /** * @js NA * @lua NA */ virtual ~Component(void); virtual bool init(); /// 进入的时候调用 virtual void onEnter(); /// 退出的时候调用 virtual void onExit(); /// 更新 virtual void update(float delta); /// 是否序列化 virtual bool serialize(void* r); /// 是否可用 virtual bool isEnabled() const; /// 设置状态 virtual void setEnabled(bool b); /// 创建一个组件 static Component* create(void); /// 得到名字 const std::string& getName() const; /// 设置名字 void setName(const std::string& name); /// 设置拥有者 void setOwner(Node *pOwner); /// 得到拥有者 Node* getOwner() const; protected: Node *_owner; std::string _name; bool _enabled; #if CC_ENABLE_SCRIPT_BINDING ccScriptType _scriptType; ///< type of script binding, lua or javascript #endif };
CCComponentContainer:
源码:
/// 组件容器 class CC_DLL ComponentContainer { protected: /** * @js ctor */ /// 构造 ComponentContainer(Node *pNode); public: /** * @js NA * @lua NA */ /// 析构 virtual ~ComponentContainer(void); /** * @js getComponent */ /// 得到组件 virtual Component* get(const std::string& name) const; /// 添加组件 virtual bool add(Component *com); /// 移除组件 virtual bool remove(const std::string& name); /// 移除组件 virtual bool remove(Component *com); /// 移除所有组件 virtual void removeAll(); /// 访问,更新所有的组件 virtual void visit(float delta); public: /// 是否是空的 bool isEmpty() const; private: /// 分配,新建的一个存储组件的Map void alloc(void); private: Map<std::string, Component*>* _components; Node *_owner; friend class Node; }; NS_CC_END
相关文章推荐
- 安装APK:Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
- 异常:org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available
- Codeforces Round #317 [AimFund Thanks-Round] (Div. 1) B. Minimization 贪心 dp
- LeetCode题解:Factorial Trailing Zeroes
- HDU2473 - Junk-Mail Filter 利用虚拟数组实现删除并查集的节点
- 【图论】【最小生成树】[IOI2003]maintain
- [捉虫记录]关于Cascade Training Error的bug
- failure during conversion to COFF: file invalid or corrupt
- 【HDOJ 1021】 Fibonacci Again (矩阵快速幂(裸))
- HDOJ 2674 N!Again(找规律)
- 人工智能进入股市操盘获利巨大激荡股市
- See You Again
- B. Order Book------(Codeforces Round #317 [AimFund Thanks-Round] (Div. 2))
- A. Arrays------(Codeforces Round #317 [AimFund Thanks-Round] (Div. 2))
- Codeforces Round #317 [AimFund Thanks-Round] (Div. 1) A. Lengthening Sticks 分类
- 1.2句柄及 WinMain函数
- ACdream 1420 High Speed Trains(容斥原理)
- MainActivity,BadgeView
- STL源码剖析 [特殊的空间配置器](机智的type_traits.h)
- http://blog.csdn.net/opennaive/article/details/7514146