0

This time I would like to ask if anybody had such strange problem with disabling button (CCMenuItemImage) in cocos2d. I have in-App-Purchase connected and when purchase is done following function is triggered

  - (void)productPurchased:(NSNotification *)notification {

        [NSObject cancelPreviousPerformRequestsWithTarget:self];
        waitingForStore = FALSE;
        [loop setVisible:FALSE];
       [buyItem setVisible:FALSE];
       //  setAccessibilityElementsHidden:YES];

        NSString *productIdentifier = (NSString *) notification.object;
        NSLog(@"Purchased: %@", productIdentifier);


    }



waitingForStore = FALSE;
 [loop setVisible:FALSE];

This two operation works fine, but the problem is with the third one. I would like to make the 'BUY' button invisible.

 [buyItem setVisible:FALSE];

This one does not do anything at this place( the button is still visible and accessible). If I will use it on the other part of code it works just fine- but here .... not. Trying to change position doesn't work neither. Could it be connected with inAppPurchase thread or something?

Cœur
  • 37,241
  • 25
  • 195
  • 267
johnnyGor
  • 161
  • 1
  • 3
  • 16

2 Answers2

0

I understand your problem. If you you want to disable menuitem you can set menuitem.isEnabled property.

And if you want to hide button, you can set property menuitem.visible = NO.

If this is not working for you can also use [menuitem runaction:[CCFadeOut actionWithDuration:1.0f] ]. Then use FadeIn as per your requirement.

This is alternative option for you.

halfer
  • 19,824
  • 17
  • 99
  • 186
Nirav Jain
  • 5,088
  • 5
  • 40
  • 61
  • Hi. Thank you for the response. Unfortunately, the only operation which is working is the CCFadeOut, trying to change the position with the action doesn't work neither. Using CCFadeOut makes it still possible to press the button, even if it is not visible at all. So I'm thinking about implementing the button style behave code based on CCSprite ( since the sprite is the only object responding for changing the visibility at this place). There is still the question ...... why :))) – johnnyGor Oct 04 '12 at 16:03
  • I have found the reason. It was my mistake when making two calls to the apple store and creating two buttons. :) So, it could be closed. – johnnyGor Oct 04 '12 at 18:09
0

I have found the reason. It was my mistake when making two calls to the apple store and creating two buttons. :) So, it could be closed.

johnnyGor
  • 161
  • 1
  • 3
  • 16