Forum > C# > Issue with CCSprite opacity and Text color

Issue with CCSprite opacity and Text color

By Logan Posted 2012-03-13 05:48 Comments 7
  • Posts: 88

i have encountered the following bugs which i couldn’t resolve.

CCLabelTTF testMessage = CCLabelTTF.labelWithString( "Hello Text ", "HUDFont", 15 );
           testMessage .Color = new ccColor3B( 255, 255, 0 );

In the above code no matter what value we set to blue value, nothing seems to happen. only colors i can set for the text is either Black, Green or Red. Is there any other method to set color to text?

this is another issue I’m unable to figure out. When we use opacity with the sprite used in progressTimer nothing seems to happen! here is the code i have used

 CCProgressTimer progressBar= CCProgressTimer.progressWithFile("SampleImage");
                 progressBar.Type = CCProgressTimerType.kCCProgressTimerTypeHorizontalBarLR;
                 progressBar.position = new CCPoint( windowSize.width / 2, windowSize.height-8 );

                 progressBar.Sprite.Opacity = 10;  // should have made the Sprite mostly transparent. But this does not happen!
                 addChild( progressBar, 102 );

I have tried varying the value of opacity but it doesn’t seem to work. please provide some suggestions.. Thanks

  • Posts: 37

#1 RE: 2012-03-13 08:53

i recommend do not use CCLabelTTF
Better use CCLabelBMFont or CCLabelAtlas

  • Posts: 88

#2 RE: 2012-03-13 09:32

will give it a try. Thanks for the reply. Can you please guide me about the other issue?

  • Posts: 171

#3 RE: 2012-03-14 02:45

Hi, Raghu, i have changed the CCSprite opacity and the Text color, and they worked well.
maybe you could try the latest code on github.

about opacity, you could set it to 100, 10 is too small, and you could see nothing, because they are nearly transparent.

  • Posts: 88

#4 RE: 2012-03-14 10:20

Thanks for the reply everyone. As for the question Guess i didn’t frame it right!? Well, like you said setting opacity to 10 must have made the object almost transparent but the problem is for me it stays opaque no matter what value i set. I have tried applying transperancy to a CCSprite it had worked as intended. The problem which i encountered occurs when sprite is used with CCProgressTimer.

Thanks for the reply, i will check the new files and report back

  • Posts: 88

#5 RE: 2012-03-26 11:20

I used the recent code. Problem still exists

  • Posts: 1

#6 RE: 2012-04-30 08:32

Like me in to this problem
I use the version cocos2d-x-for-xna-0.1.0

  • Posts: 3

#7 RE: 2012-05-09 02:18

The label color issue comes from cocos2d-xna/textures/CCTexture2D.cs in the line:

 app.spriteBatch.DrawString(font, text, new Vector2(0, 0), Color.YellowGreen, 0.0f, origin, scale, SpriteEffects.None, 0.0f); 

should use Color.White instead.

Loggin to reply

Copyright © 2010 - 2013 Cocos2d-x.orgClustrmaps