Class cc.Menu

Class Summary
Constructor Attributes Constructor Name and Description
 

Features and Limitation:
- You can add MenuItem objects in runtime using addChild:
- But the only accepted children are MenuItem objects

Method Summary

Class Detail

cc.Menu()

Features and Limitation:
- You can add MenuItem objects in runtime using addChild:
- But the only accepted 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
  • <static> {cc.Menu} cc.Menu.create(menuItems)
    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);
    Parameters:
    {...cc.MenuItem|null} menuItems
    Returns:
    {cc.Menu}
  • {cc.Color3B} getColor()
    Returns:
    {cc.Color3B}
  • {Number} getOpacity()
    Returns:
    {Number}
  • {Boolean} initWithArray(arrayOfItems)
    initializes a cc.Menu with a Array of cc.MenuItem objects
    Parameters:
    {Array} arrayOfItems
    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}
  • 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