CCMenu解析
来源:互联网 发布:vmware mac os 10.9 编辑:程序博客网 时间:2024/05/22 15:38
代码:
/** @brief A Menu for touch handling.* * Features and Limitation:* - You can add MenuItem objects in runtime using addChild.* - But the only accepted children are MenuItem objects.*/// 处理触摸事件的菜单// 特点和限制:可以在运行的时候使用addChild添加MenuItem对象// 但是,只能添加MenuItem类型的对象class CC_DLL Menu : public Layer{public: /** * Menu state, it's used internally. */ enum class State { WAITING, TRACKING_TOUCH, }; /** *@brief Creates an empty Menu. */ // 创建一个菜单 static Menu* create(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) // WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported. typedef MenuItem* M; static Menu* create(M m1, std::nullptr_t listEnd) { return variadicCreate(m1, NULL); } static Menu* create(M m1, M m2, std::nullptr_t listEnd) { return variadicCreate(m1, m2, NULL); } static Menu* create(M m1, M m2, M m3, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, NULL); } static Menu* create(M m1, M m2, M m3, M m4, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, NULL); } static Menu* create(M m1, M m2, M m3, M m4, M m5, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, NULL); } static Menu* create(M m1, M m2, M m3, M m4, M m5, M m6, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, NULL); } static Menu* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, NULL); } static Menu* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, NULL); } static Menu* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, m9, NULL); } static Menu* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, M m10, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, NULL); } // On WP8 for lists longer than 10 items, use createWithArray or variadicCreate with NULL as the last argument. static Menu* variadicCreate(MenuItem* item, ...);#else /** Creates a Menu with MenuItem objects. */ static Menu* create(MenuItem* item, ...) CC_REQUIRES_NULL_TERMINATION;#endif /** * Creates a Menu with a Array of MenuItem objects. * @js NA */ // 通过MenuItem数组创建一个菜单 static Menu* createWithArray(const Vector<MenuItem*>& arrayOfItems); /** * Creates a Menu with it's item, then use addChild() to add * other items. It is used for script, it can't init with undetermined * number of variables. * @js NA */ static Menu* createWithItem(MenuItem* item); /** Creates a Menu with MenuItem objects. * @js NA */ static Menu* createWithItems(MenuItem *firstItem, va_list args); /** Align items vertically. */// 在竖直方向上拍成一条线 void alignItemsVertically(); /** Align items vertically with padding. @since v0.7.2 */// 在竖直方向上拍成一条线,同时有内边距 void alignItemsVerticallyWithPadding(float padding); /** Align items horizontally. */// 在水平方向上拍成一条线 void alignItemsHorizontally(); /** Align items horizontally with padding. @since v0.7.2 */// 在水平方向上拍成一条线,同时有内边距 void alignItemsHorizontallyWithPadding(float padding); /** Align items in rows of columns. */// 将项目列为行 void alignItemsInColumns(int columns, ...) CC_REQUIRES_NULL_TERMINATION; /** Align items in rows of columns. */ void alignItemsInColumns(int columns, va_list args); /** Align items in array of columns. * @js NA */ // 将项目拍成一列,通过行数组 void alignItemsInColumnsWithArray(const ValueVector& rows); /** Align items in columns of rows. */ void alignItemsInRows(int rows, ...) CC_REQUIRES_NULL_TERMINATION; /** Align items in columns of rows. */ void alignItemsInRows(int rows, va_list args); /** Align items in array of rows. * @js NA */ // 将项目拍成行 void alignItemsInRowsWithArray(const ValueVector& columns); /** * Determines if the menu is enable. * @see `setEnabled(bool)`. * @return whether the menu is enabled or not. */ // 是否可用 virtual bool isEnabled() const { return _enabled; } /** * Set whether the menu is visible. * The default value is true, a menu is default to visible. *@param value true if menu is enable, false if menu is disable. */ // 设置是否可用 virtual void setEnabled(bool value) { _enabled = value; }; virtual bool onTouchBegan(Touch* touch, Event* event) override; virtual void onTouchEnded(Touch* touch, Event* event) override; virtual void onTouchCancelled(Touch* touch, Event* event) override; virtual void onTouchMoved(Touch* touch, Event* event) override; // overrides virtual void removeChild(Node* child, bool cleanup) override; virtual void addChild(Node * child) override; virtual void addChild(Node * child, int zOrder) override; virtual void addChild(Node * child, int zOrder, int tag) override; virtual void addChild(Node * child, int zOrder, const std::string &name) override; virtual void onEnter() override; virtual void onExit() override; virtual void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);} virtual bool isOpacityModifyRGB(void) const override { return false;} virtual std::string getDescription() const override;CC_CONSTRUCTOR_ACCESS: /** * @js ctor */ Menu() : _selectedItem(nullptr) {} virtual ~Menu(); /** initializes an empty Menu */ bool init() override; /** initializes a Menu with a NSArray of MenuItem objects */ bool initWithArray(const Vector<MenuItem*>& arrayOfItems);protected: /** whether or not the menu will receive events */ bool _enabled; MenuItem* getItemForTouch(Touch * touch); State _state; MenuItem *_selectedItem;private: CC_DISALLOW_COPY_AND_ASSIGN(Menu);};
0 0
- CCMenu解析
- CCMenu
- CCMenu CCMenuItem
- CCMenu 菜单
- CCMenuItemFont CCmenu
- 关于CCMenu~~
- CCMenu响应touchmove事件
- cocos2d-iphone CCMenu
- 八、CCMenu和CCMenuItem
- 菜单之CCMenu
- cocos2d-x、CCMenu、CCMenuItem
- cocos2dx教程之CCMenu
- cocos2d-x CCMenu 菜单
- 八、CCMenu和CCMenuItem
- CCMenu的创建
- 八、CCMenu和CCMenuItem
- Cocos2dx:菜单(CCMenu,CCMenuItem)
- cocos2dx-CCMenu菜单
- ConcurrentModificationException异常解决
- 集群,分布式,负载均衡区别联系
- 面试题:(1)关于fork的问题
- hihocoder1163 nim博弈
- github-july-字符串的全排列
- CCMenu解析
- 如何在点击shell/elisp类型的link时,不要弹出确认窗口
- Coursera机器学习课程笔记(5) Neural Networks Representation
- UVA 1451 - Average
- 【h5-egret】js加载成第三方库
- OpenCV 重映射
- UVALive 6625_状态压缩
- 聚类算法分析——Kmeans算法
- 菜鸟学飞记——proc的那些事