Class cc.Menu
Constructor Attributes | Constructor Name and Description |
---|---|
cc.Menu(menuItems})
Features and Limitation: |
Method Summary
Class Detail
Features and Limitation:
- You can add MenuItem objects in runtime using addChild:
- But the only accepted children are MenuItem objects
var layer = new cc.Menu(menuitem1, menuitem2, menuitem3);
- Parameters:
- {...cc.MenuItem|null} menuItems}
Method Detail
-
addChild(child, zOrder, tag)add a child for cc.Menu
- Parameters:
- {cc.Node} child
- {Number|Null} zOrder Optional
- zOrder for the child
- {Number|Null} tag Optional
- tag for the child
-
alignItemsHorizontally()align items horizontally with default padding
-
alignItemsHorizontallyWithPadding(padding)align items horizontally with specified padding
- Parameters:
- {Number} padding
-
alignItemsInColumns()align items in columns
// Example menu.alignItemsInColumns(3,2,3)// this will create 3 columns, with 3 items for first column, 2 items for second and 3 for third menu.alignItemsInColumns(3,3)//this creates 2 columns, each have 3 items
-
alignItemsInRows()align menu items in rows
// Example menu.alignItemsInRows(5,3)//this will align items to 2 rows, first row with 5 items, second row with 3 menu.alignItemsInRows(4,4,4,4)//this creates 4 rows each have 4 items
- Parameters:
- {Number}
-
alignItemsVertically()align items vertically with default padding
-
alignItemsVerticallyWithPadding(padding)align items vertically with specified padding
- Parameters:
- {Number} padding
-
create a new menu
- Parameters:
- {...cc.MenuItem|null} menuItems
- todo: need to use new
- Deprecated:
- since v3.0, please use new cc.Menu(menuitem1, menuitem2, menuitem3) to create a new menu
- Returns:
- {cc.Menu}
-
ctor(menuItems)Constructor of cc.Menu override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- Parameters:
- {...cc.MenuItem|null} menuItems
-
{Boolean} initWithArray(arrayOfItems)initializes a cc.Menu with a Array of cc.MenuItem objects
- Parameters:
- {Array} arrayOfItems
- array Of cc.MenuItem Items
- Returns:
- {Boolean}
-
{Boolean} initWithItems(args)initializes a cc.Menu with it's items
- Parameters:
- {Array} args
- Returns:
- {Boolean}
-
{Boolean} isEnabled()return whether or not the menu will receive events
- Returns:
- {Boolean}
-
{boolean} isOpacityModifyRGB()only use for jsbinding
- Returns:
- {boolean}
-
onEnter()
Event callback that is invoked every time when CCMenu enters the 'stage'.
If the CCMenu enters the 'stage' with a transition, this event is called when the transition starts.
During onEnter you can't access a "sister/brother" node.
If you override onEnter, you must call its parent's onEnter function with this._super(). -
onExit()
callback that is called every time the cc.Menu leaves the 'stage'.
If the cc.Menu leaves the 'stage' with a transition, this callback is called when the transition finishes.
During onExit you can't access a sibling node.
If you override onExit, you shall call its parent's onExit with this._super(). -
removeChild(child, cleanup)remove a child from cc.Menu
- Parameters:
- {cc.Node} child
- the child you want to remove
- {boolean} cleanup
- whether to cleanup
-
setEnabled(enabled)set whether or not the menu will receive events
- Parameters:
- {Boolean} enabled
-
setOpacityModifyRGB(value)only use for jsbinding
- Parameters:
- value