Class cc.MenuItemImage

Class Summary
Constructor Attributes Constructor Name and Description
 
cc.MenuItemImage accepts images as items.

Method Summary

Class Detail

cc.MenuItemImage()
cc.MenuItemImage accepts images as items.
The images has 3 different states:
- unselected image
- selected image
- disabled image

For best results try that all images are of the same size

Method Detail

  • <static> {cc.MenuItemImage} cc.MenuItemImage.create(normalImage, selectedImage, three, four, five)
    creates a new menu item image
    // Example
    //create a dom menu item with normal and selected state, when clicked it will run the run function from gameScene object
    var item = cc.MenuItemImage.create('normal.png', 'selected.png', 'run', gameScene)
    
    //same as above, but pass in the actual function and disabled image
    var item = cc.MenuItemImage.create('normal.png', 'selected.png', 'disabled.png', gameScene.run, gameScene)
    Parameters:
    {String} normalImage
    file name for normal state
    {String} selectedImage
    image for selected state
    {String|cc.Node} three
    Disabled image OR callback function
    {String|function|Null} four Optional
    callback function, either name in string or pass the whole function OR the target
    {cc.Node|String|function|Null} five Optional
    cc.Node target to run callback when clicked
    Returns:
    {cc.MenuItemImage}
  • {boolean} initWithNormalImage(normalImage, selectedImage, disabledImage, callback, target)
    Parameters:
    {string|null} normalImage
    {string|null} selectedImage
    {string|null} disabledImage
    {function|string|null} callback
    {cc.Node|null} target
    Returns:
    {boolean}
  • setDisabledSpriteFrame(frame)
    sets the sprite frame for the disabled image
    Parameters:
    {cc.SpriteFrame} frame
  • setNormalSpriteFrame(frame)
    sets the sprite frame for the normal image
    Parameters:
    {cc.SpriteFrame} frame
  • setSelectedSpriteFrame(frame)
    sets the sprite frame for the selected image
    Parameters:
    {cc.SpriteFrame} frame