Class cc.Menu
- Defined in: CCMenu.js
- Extends cc.LayerRGBA
Constructor Attributes | Constructor Name and Description |
---|---|
cc.Menu()
Features and Limitation: |
Method Summary
Class Detail
cc.Menu()
Features and Limitation:
- You can add MenuItem objects in runtime using addChild:
- But the only accecpted children are MenuItem objects
Method Detail
-
addChild(child, zOrder, tag)
- Parameters:
- {cc.Node} child
- {Number|Null} zOrder Optional
- {Number|Null} tag Optional
-
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
-
alignItemsVertically()align items vertically with default padding
-
alignItemsVerticallyWithPadding(padding)align items vertically with specified padding
- Parameters:
- {Number} padding
-
create a new menu
// Example //there is no limit on how many menu item you can pass in var myMenu = cc.Menu.create(menuitem1, menuitem2, menuitem3);
- Returns:
- {cc.Menu}
-
{cc.Color3B} getColor()
- Returns:
- {cc.Color3B}
-
{Number} getOpacity()
- Returns:
- {Number}
-
initWithArray(arrayOfItems)initializes a cc.Menu with a Array of cc.MenuItem objects
- Parameters:
- arrayOfItems
-
{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}
-
onExit()custom on exit
-
{Boolean} onTouchBegan(touch, e)
- Parameters:
- {cc.Touch} touch
- {Object} e
- Returns:
- {Boolean}
-
onTouchCancelled(touch, e)touch cancelled
- Parameters:
- touch
- e
-
onTouchEnded(touch, e)when a touch ended
- Parameters:
- touch
- e
-
onTouchMoved(touch, e)touch moved
- Parameters:
- {cc.Touch} touch
- {Object} e
-
registerWithTouchDispatcher()make the menu clickable
-
removeChild(child, cleanup)
- Parameters:
- {cc.Node} child
- {boolean} cleanup
-
setColor(color)
- Parameters:
- {cc.Color3B} color
-
setEnabled(enabled)set whether or not the menu will receive events
- Parameters:
- {Boolean} enabled
-
setHandlerPriority(newPriority)set event handler priority. By default it is: kCCMenuTouchPriority
- Parameters:
- {Number} newPriority
-
setOpacity(opa)
- Parameters:
- {Number} opa