I'm having problems using CCMenu with scaled CCMenuItemSprite menu items. I'm trying to scale the menu item sprites differently based on which device the game is being played on (the iPad needs to scale it to about 1.5x, whereas on the iPhone it's about 0.75x)
From what I've read, we can't scale the CCSprite directly, or the CCMenuItemSprite, because when it's added to the CCMenu the touch rectangles aren't updated correctly. I believe that I have to scale the CCMenu to scale the Menu Items.
Whenever I do this my sprites appear to be scaled to the correct sizes, however it also seems to scale the CCMenu position coordinates, but in the opposite direction as what I'd expect. Also once I go over a certain threshold the menu seems to disappear altogether.
Does anyone have any suggestions on how I should be scaling Sprites in a CCMenu?
Thanks in advance. Buzzrick
Try this Code........
CCMenuItemImage *Btn1 = [CCMenuItemImage itemWithNormalImage:@"button1.png" selectedImage:@"button1_active.png" target:self selector:@selector(button1_click:)];
CCMenuItemImage *Btn2 = [CCMenuItemImage itemWithNormalImage:@"button2.png" selectedImage:@"button2_active.png" target:self selector:@selector(button2_click:)];
CCMenu *Action_menu = [CCMenu menuWithItems:Btn1,Btn2, nil];
[Action_menu setPosition:ccp( 79, 288)];
float delayTime = 0.3f;
for (CCMenuItemFont *each in [Action_menu children])
{
each.scaleX = 0.0f;
each.scaleY = 0.0f;
CCAction *action = [CCSequence actions:
[CCDelayTime actionWithDuration: delayTime],
[CCScaleTo actionWithDuration:0.5F scale:1.0],
nil];
delayTime += 0.2f;
[each runAction: action];
}
[self addChild:Action_menu];