Domanda

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?

È stato utile?

Soluzione

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"] ];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top