Class cc.MenuItemSprite
- Defined in: CCMenuItem.js
- Extends cc.MenuItem
Constructor Attributes | Constructor Name and Description |
---|---|
CCMenuItemSprite accepts CCNode
|
Method Summary
Class Detail
cc.MenuItemSprite()
CCMenuItemSprite accepts CCNode objects as items.
The images has 3 different states:
- unselected image
- selected image
- disabled image
The images has 3 different states:
- unselected image
- selected image
- disabled image
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.Color3B} getColor()
- Returns:
- {cc.Color3B}
-
{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.Color3B} 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