Cocos2D CCButton setBackgroundColor not working -


i added following code cocos2d default template's introscene:

ccbutton *playbutton = [ccbutton buttonwithtitle:@"play" fontname:@"helveticaneue" fontsize:18.0f]; [playbutton setbackgroundcolor:[cccolor colorwithwhite:0.7f alpha:1.0f] forstate:cccontrolstatenormal]; [playbutton setbackgroundcolor:[cccolor colorwithwhite:0.75f alpha:1.0f] forstate:cccontrolstatehighlighted]; playbutton.positiontype = ccpositiontypenormalized; playbutton.position = ccp(0.5f, 0.35f); playbutton.zoomwhenhighlighted = no; playbutton.preferredsize = cgsizemake(222, 46); [playbutton settarget:self selector:@selector(onspinningclicked:)]; [self addchild:playbutton]; 

for reason button has no background color. ideas?

because didn't set color, brightness (this "white" means in context of cccolor).

try using color initializer:

cccolor* normalcolor = [cccolor colorwithred:1.0 green:0.0 blue:0.0 alpha:1.0f] [playbutton setbackgroundcolor:normalcolor forstate:cccontrolstatenormal]; 

this make button background red.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -