Class cc.MenuItemImage

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

Method Summary

Class Detail

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)
    {String} normalImage
    file name for normal state
    {String} selectedImage
    image for selected state
    {String|cc.Node} three
    Disabled image OR allback function
    {String|function|Null} four
    callback function, either name in string or pass the whole function OR the target
    {cc.Node|String|function|Null} five
    cc.Node target to run callback when clicked
  • {boolean} initWithNormalImage(normalImage, selectedImage, disabledImage, callback, target)
    {string|null} normalImage
    {string|null} selectedImage
    {string|null} disabledImage
    {function|string|null} callback
    {cc.Node|null} target
  • setDisabledSpriteFrame(frame)
    sets the sprite frame for the disabled image
    {cc.SpriteFrame} frame
  • setNormalSpriteFrame(frame)
    sets the sprite frame for the normal image
    {cc.SpriteFrame} frame
  • setSelectedSpriteFrame(frame)
    sets the sprite frame for the selected image
    {cc.SpriteFrame} frame