DNESS / cocos2d-iphone

Automatically exported from code.google.com/p/cocos2d-iphone
1 stars 0 forks source link

Text in CCMenuItemToggle keeps growing on rapid tap #1129

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Setup a CCMenu with CCMenuItemToggle containing two 
CCMenuItemLabel/CCMenuItemFont items

like in MenuTest application in Cocos2d test applications.

"
CCMenuItemToggle *item1 = [CCMenuItemToggle itemWithTarget:self 
selector:@selector(menuCallback:) items:
                                 [CCMenuItemFont itemFromString: @"On"],
                                 [CCMenuItemFont itemFromString: @"Off"],
                                 nil];
"
2. Go in MenuTest application to "Configuration" menu and tap repeatedly on 
"On/Off" menu item
3.

What is the expected output? What do you see instead?

"On" and "Off" labels alternate with a zoom effect and upon tap release the 
size of the "On"/"Off" labels returns to their original sizes.

Instead:

The size of the "On"/"Off" labels are keep growing. 

What cocos2d version are you using ?

cocos2d v1.0.0-beta

What iOS / Mac SDK are you using ?

iOS 4.2.1

Debug or Release ?

Both

Which target device / target OS are you using ?

iPod touch 2nd gen/iPhone 3GS

iOS only: Does this happens on device ? or on the simulator ? or on both ?

Both

Mac only: x86 or i386 ?

Please provide any additional information below.

The problem is here:

In CCMenuItem.m

@implementation CCMenuItemLabel

-(void) selected
{
    // subclass to change the default action
    if(isEnabled_) {    
        [super selected];
        [self stopActionByTag:kZoomActionTag];
        originalScale_ = self.scale;       <==== This is the problem
        CCAction *zoomAction = [CCScaleTo actionWithDuration:0.1f scale:originalScale_ * 1.2f];
        zoomAction.tag = kZoomActionTag;
        [self runAction:zoomAction];
    }
}

@end

originalScale_ value is overwritten every time the menu item gets to selected 
state. and if the previous action with kZoomActionTag is stopped before it 
finishes self.scale is not in its original value. So the real original value is 
lost. As a result the scale factor keeps growing.

One easy fix for this to comment out the "originalScale_ = self.scale;" line 
but this is not the full solution in case original scale value is not 1.

Original issue reported on code.google.com by attila.b...@gmail.com on 7 Mar 2011 at 7:29

GoogleCodeExporter commented 9 years ago

Original comment by ricardoq...@gmail.com on 17 Mar 2011 at 7:00

GoogleCodeExporter commented 9 years ago

Original comment by ricardoq...@gmail.com on 17 Mar 2011 at 7:01