Hi, can we give pressed over effect to a button with out having its over effect graphic.
I have only one graphic for button. I just want to darken my button when pressed down.
thanks in advance
A fast, easy to use, free, and community supported 2D game engine
Hi, can we give pressed over effect to a button with out having its over effect graphic.
I have only one graphic for button. I just want to darken my button when pressed down.
thanks in advance
Hi,
If I understand you correctly, you have one graphic, and would like to use it for the normal and selected states of the button, right?
So, maybe you could adjust the color of the sprite. Or the opacity even?
For example:
CCSprite *spriteNormal = [CCSprite spriteWithFile:@"MySprite.png"];
CCSprite *spriteSelected = [CCSprite spriteWithFile:@"MySprite.png"];
[spriteSelected setColor:ccc3(128, 128, 128)];
CCSprite *spriteDisabled = [CCSprite spriteWithFile:@"MySprite.png"];
[spriteDisabled setColor:ccc3(64,64,64)];
[spriteDisabled setOpacity:192];
CCMenuItemSprite *item1 = [CCMenuItemSprite itemFromNormalSprite:spriteNormal selectedSprite:spriteSelected disabledSprite:spriteDisabled target:self selector:@selector(menuCallback:)];
CCMenu *menu = [CCMenu menuWithItems:item1, nil];
[self addChild:menu];
** color and opacity both use GLubyte values
HTH,
-Mark
thanks it works
You must log in to post.