Class cc.MenuItemSprite

Class Summary
Constructor Attributes Constructor Name and Description
 
CCMenuItemSprite accepts CCNode objects as items.

Method Summary

Class Detail

cc.MenuItemSprite()
CCMenuItemSprite accepts CCNode objects as items.
The images has 3 different states:
- unselected image
- selected image
- disabled image

Field Detail

{cc.Sprite} disabledImage
- Sprite in disabled state
{cc.Sprite} normalImage
- Sprite in normal state
{cc.Sprite} selectedImage
- Sprite in selected state

Method Detail

  • <static> {cc.MenuItemSprite} cc.MenuItemSprite.create(normalSprite, selectedSprite, three, four, five)
    create a menu item from sprite
    // Example
    var item = cc.MenuItemSprite.create(normalImage)//create a menu item from a sprite with no functionality
    
    var item = cc.MenuItemSprite.create(normalImage, selectedImage)//create a menu Item, nothing will happen when clicked
    
    var item = cc.MenuItemSprite.create(normalImage, SelectedImage, disabledImage)//same above, but with disabled state image
    
    var item = cc.MenuItemSprite.create(normalImage, SelectedImage, 'callback', targetNode)//create a menu item, when clicked runs targetNode.callback()
    
    var item = cc.MenuItemSprite.create(normalImage, SelectedImage, disabledImage, targetNode.callback, targetNode)
    //same as above, but with disabled image, and passing in callback function
    Parameters:
    {Image} normalSprite
    normal state image
    {Image|Null} selectedSprite
    selected state image
    {Image|cc.Node|Null} three
    disabled state image OR target node
    {String|function|cc.Node|Null} four
    callback function name in string or actual function, OR target Node
    {String|function|Null} five
    callback function name in string or actual function
    Returns:
    {cc.MenuItemSprite}
  • {cc.Color} getColor()
    Returns:
    {cc.Color}
  • {cc.Sprite} getDisabledImage()
    Returns:
    {cc.Sprite}
  • {cc.Sprite} getNormalImage()
    Returns:
    {cc.Sprite}
  • {Number} getOpacity()
    Returns:
    {Number} opacity from 0 - 255
  • {cc.Sprite} getSelectedImage()
    Returns:
    {cc.Sprite}
  • {Boolean} initWithNormalSprite(normalSprite, selectedSprite, disabledSprite, callback, target)
    Parameters:
    {cc.Node} normalSprite
    {cc.Node} selectedSprite
    {cc.Node} disabledSprite
    {function|String} callback
    {cc.Node} target
    Returns:
    {Boolean}
  • selected()
    menu item is selected (runs callback)
  • setColor(color)
    Parameters:
    {cc.Color} color
  • setDisabledImage(disabledImage)
    Parameters:
    {cc.Sprite} disabledImage
  • setEnabled(bEnabled)
    Parameters:
    {Boolean} bEnabled
  • setNormalImage(normalImage)
    Parameters:
    {cc.Sprite} normalImage
  • setOpacity(opacity)
    Parameters:
    {Number} opacity
    0 - 255
  • setSelectedImage(selectedImage)
    Parameters:
    {cc.Sprite} selectedImage
  • unselected()
    menu item goes back to unselected state