Class cc.Menu
Extends
cc.Layer.
Defined in: CCMenu.js.
Constructor Attributes | Constructor Name and Description |
---|---|
cc.Menu()
Features and Limitation: |
Method Attributes | Method Name and Description |
---|---|
addChild(child, zOrder, tag)
|
|
align items horizontally with default padding
|
|
alignItemsHorizontallyWithPadding(padding)
align items horizontally with specified padding
|
|
align items in columns
|
|
align menu items in rows
|
|
align items vertically with default padding
|
|
alignItemsVerticallyWithPadding(padding)
align items vertically with specified padding
|
|
<static> |
cc.Menu.create()
create a new menu
|
getColor()
|
|
initWithArray(arrayOfItems)
initializes a cc.Menu with a Array of cc.MenuItem objects
|
|
initWithItems(args)
initializes a cc.Menu with it's items
|
|
return whether or not the menu will receive events
|
|
onExit()
custom on exit
|
|
onTouchBegan(touch, e)
|
|
onTouchCancelled(touch, e)
touch cancelled
|
|
onTouchEnded(touch, e)
when a touch ended
|
|
onTouchMoved(touch, e)
touch moved
|
|
make the menu clickable
|
|
setColor(color)
|
|
setEnabled(enabled)
set whether or not the menu will receive events
|
|
setHandlerPriority(newPriority)
set event handler priority.
|
|
setOpacity(opa)
|
|
setOpacityModifyRGB(value)
|
- Methods borrowed from class cc.Layer:
- ctor, didAccelerate, getMousePriority, getTouchMode, getTouchPriority, init, isAccelerometerEnabled, isKeyboardEnabled, isMouseEnabled, isTouchEnabled, onEnter, onEnterTransitionDidFinish, onMouseDown, onMouseDragged, onMouseEntered, onMouseExited, onMouseMoved, onMouseUp, onOtherMouseDown, onOtherMouseDragged, onOtherMouseUp, onRightMouseDown, onRightMouseDragged, onRightMouseUp, onScrollWheel, onTouchesBegan, onTouchesCancelled, onTouchesEnded, onTouchesMoved, setAccelerometerEnabled, setKeyboardEnabled, setMouseEnabled, setMousePriority, setTouchEnabled, setTouchMode, setTouchPriority
- Methods borrowed from class cc.Node:
- cleanup, convertToNodeSpace, convertToNodeSpaceAR, convertTouchToNodeSpace, convertTouchToNodeSpaceAR, convertToWorldSpace, convertToWorldSpaceAR, description, draw, getActionByTag, getActionManager, getAnchorPoint, getAnchorPointInPoints, getBoundingBox, getBoundingBoxToWorld, getCamera, getChildByTag, getChildren, getChildrenCount, getContentSize, getGLServerState, getGrid, getOrderOfArrival, getParent, getPosition, getPositionX, getPositionY, getRotation, getScale, getScaleX, getScaleY, getScheduler, getShaderProgram, getSkewX, getSkewY, getTag, getUserData, getUserObject, getVertexZ, getZOrder, ignoreAnchorPointForPosition, isIgnoreAnchorPointForPosition, isRunning, isVisible, nodeToParentTransform, nodeToWorldTransform, numberOfRunningActions, onExitTransitionDidStart, parentToNodeTransform, pauseSchedulerAndActions, release, removeAllChildren, removeAllChildrenWithCleanup, removeChild, removeChildByTag, removeFromParent, removeFromParentAndCleanup, reorderChild, resumeSchedulerAndActions, retain, runAction, schedule, scheduleOnce, scheduleUpdate, scheduleUpdateWithPriority, setActionManager, setAnchorPoint, setContentSize, setGLServerState, setGrid, setNodeDirty, setOrderOfArrival, setParent, setPosition, setPositionX, setPositionY, setRotation, setScale, setScaleX, setScaleY, setScheduler, setShaderProgram, setSkewX, setSkewY, setTag, setUserData, setUserObject, setVertexZ, setVisible, setZOrder, sortAllChildren, stopAction, stopActionByTag, stopAllActions, transform, transformAncestors, unschedule, unscheduleAllCallbacks, unscheduleUpdate, update, updateTransform, visit, worldToNodeTransform
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
- {Number|Null} tag
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()
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}
isOpacityModifyRGB()
onExit()
custom on exit
{Boolean}
onTouchBegan(touch, e)
- Parameters:
- {cc.Touch} touch
- 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
- e
registerWithTouchDispatcher()
make the menu clickable
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
setOpacityModifyRGB(value)
- Parameters:
- value