1

I'm trying to make a CCMenuItem (e.g. CCMenuItemSprite) clickable in a disabled state.

I've subclassed CCMenuItemSprite and overwritten these functions:

    -(void) selected
    {
         CCLOG(@"selected");
         [super selected];

         [self setScale:0.775];
         [normalImage_ setVisible:NO];
         [selectedImage_ setVisible:YES];
         [disabledImage_ setVisible:NO];
     }

     -(void) unselected
    {
        CCLOG(@"unselected");
        [super unselected];

        [self setScale:1];
        [normalImage_ setVisible:YES];
        [selectedImage_ setVisible:NO];
        [disabledImage_ setVisible:NO];
    }

    -(void) activate
    {
        CCLOG(@"activate");

        if( block_ )
             block_(self);
    }

Basically I took out the flag check isEnabled_ from those three functions. I have logic in my scene to deselect everything if anything but the buttons are pressed (including close the menu). What's happening right now is after the button is pressed, its disabled. If I try to press it again it'll just close everything like the button isn't there.

What I need is for these buttons to be clickable in a disabled state (it'll run selected and unselected but not activate). Anyone know how to do this?

David Zhang
  • 346
  • 2
  • 13

1 Answers1

0

clickable in a disabled state? Then why you disable menu button? Just change normal image to disable image frame.

[menuBtn setNormalImage:[CCSprite spriteWithSpriteFrame:@"frameDisableBtn.png"] ];
[menuBtn setSelectedImage:[CCSprite spriteWithSpriteFrame:@"frameDisableBtn.png"] ];
Guru
  • 21,652
  • 10
  • 63
  • 102
  • Is there another way to remove the check for the disabled flag somewhere? What does the disabled flag actually do? I guess I can do this, just feels bad to create another flag if there is already pre built functionality for this – David Zhang Apr 10 '13 at 20:31