1

I have a CCMenuItemLabel on my scene, and when I press and hold my finger on the label it grows in size. Now I dont want that and I dont know how to do this.

I've searched for cocos2d ccmenuitemlabel hover but didnt find what I was searching for.

Arbitur
  • 38,684
  • 22
  • 91
  • 128

2 Answers2

4

Extend CCMenuItemLabel and override two methods

-(void) selected {
    if(isEnabled_) {
        isSelected_=YES;
        // do your own anim here (or not !)
    }
}

-(void) unselected {
    if(isEnabled_) {
        isSelected_=YES;
        // undo whatever you did 
    }
}
YvesLeBorg
  • 9,070
  • 8
  • 35
  • 48
0

You can disable touches for the menu this item is contained in by setting isTouchEnabled to NO. If your menu contains other items than just create the labels in a different menu.

It is cumbersome but it will work.

giorashc
  • 13,691
  • 3
  • 35
  • 71
  • it is, cocos2d enlarges the embedded label by 5% when CCMenu calls the selected method, and shrinks it back when CCMenu calls the unselected method. – YvesLeBorg Apr 06 '13 at 11:05
  • hmm, talk about bad coupling. imao this should be optional or seperated in another class – giorashc Apr 06 '13 at 12:04
  • 1
    totally ... at the very least they should have a property for the scaling on select (defaults to 1.0). Not only that, they chose to implement that with an action, and in tight monkey testing, you can create the 'ever growing' label. I subclassed that thing on day one, never looked back. – YvesLeBorg Apr 06 '13 at 12:12