Class cc.MenuItemToggle
- Defined in: CCMenuItem.js
- Extends cc.MenuItem
Constructor Attributes | Constructor Name and Description |
---|---|
A simple container class that "toggles" it's inner items
The inner items can be any MenuItem |
Method Summary
Class Detail
cc.MenuItemToggle()
A simple container class that "toggles" it's inner items
The inner items can be any MenuItem
The inner items can be any MenuItem
Method Detail
-
activate()activate the menu item
-
addSubItem(item)
- Parameters:
- {cc.MenuItem} item
-
create a simple container class that "toggles" it's inner items
The inner items can be any MenuItem// Example //create a toggle item with 2 menu items (which you can then toggle between them later) var toggler = cc.MenuItemToggle.create( cc.MenuItemFont.create("On"), cc.MenuItemFont.create("Off"), this.callback, this) //Note: the first param is the target, the second is the callback function, afterwards, you can pass in any number of menuitems //if you pass only 1 variable, then it must be a cc.MenuItem var notYetToggler = cc.MenuItemToggle.create(cc.MenuItemFont.create("On"));//it is useless right now, until you add more stuff to it notYetToggler.addSubItem(cc.MenuItemFont.create("Off")); //this is useful for constructing a toggler without a callback function (you wish to control the behavior from somewhere else)
- Returns:
- {cc.MenuItemToggle}
-
{cc.Color3B} getColor()
- Returns:
- {cc.Color3B}
-
{Number} getOpacity()
- Returns:
- {Number}
-
{Number} getSelectedIndex()
- Returns:
- {Number}
-
{cc.MenuItem} getSubItems()similar to get children
- Returns:
- {cc.MenuItem}
-
{Boolean} initWithItems(args[last-1], args[last])
- Parameters:
- {cc.MenuItem} args[0...last-2]
- the rest in the array are cc.MenuItems
- {function|String} args[last-1]
- the second item in the args array is the callback
- {cc.Node} args[last]
- the first item in the args array is a target
- Returns:
- {Boolean}
-
selected()menu item is selected (runs callback)
-
{cc.MenuItem} selectedItem()returns the selected item
- Returns:
- {cc.MenuItem}
-
setColor(Color)
- Parameters:
- {cc.Color3B} Color
-
setEnabled(enabled)
- Parameters:
- {Boolean} enabled
-
setOpacity(Opacity)
- Parameters:
- {Number} Opacity
-
setSelectedIndex(SelectedIndex)
- Parameters:
- {Number} SelectedIndex
-
setSubItems(SubItems)
- Parameters:
- {cc.MenuItem} SubItems
-
unselected()menu item goes back to unselected state