HomeForumsGeneral DiscussionCCLabel background color

This topic has 3 voices, contains 5 replies, and was last updated by  Pete 145 days ago.

Viewing 6 posts - 1 through 6 (of 6 total)
Author Posts
Author Posts
November 19, 2010 at 7:04 pm #248

stahlmanDesign

I want to make my characters display a message when spoken to or when the hero is in the vicinity, so I added a CCLabel that appears about the characters and follows them around.

The problem is that I can’t make the background transparent. What seems to happen is that when the CCLabel is first created, it samples the background around the text box to create a sprite. In my example screen shot the Skeleton and Spider started on a yellow background and you can see how they carry that original yellow wherever they go. Even if the background is transparent in Tiled, meaning it’s black in the game, the sampled area in the CCLabel is black and not transparent.

I’m using CCLabel because it’s not “slow” as is commonly believed unless you are updating it constantly.

But maybe that’s what I must do if it’s going to be moving around. In that case I guess I’d need to use CCLabelAtlas or CCBitmapFontAtlas instead.

Is there a way to make it transparent without updating it constantly ?

November 19, 2010 at 7:11 pm #880

CyberGreg

Check out CCNotifications -> LINK

It’s now a part of cocos2d 0.99.5 rc and up. Manucorporat developed it mainly for OpenFeint notifications but it works great as an all-purpose animated window.

Oops sorry, to get rid of the black you need to make your own CCLabel extension just like CCZSprite. I made mine with CZLabelBMFont.

October 1, 2011 at 11:16 am #2080

Pete

Justin, did you ever resolve this? When I display text using CCLabelBMFont, the lowest level in Tiled is being displayed as a background to the text (black if it’s transparent, green if it’s grass etc).

Any help much appreciated!

December 23, 2011 at 11:29 pm #2229

Pete

CyberGreg, could you post the core code for your CZLabelBMFont please? I’ve looked at CCZSprite but I just can’t get my head around it at the moment (I’ve tried sleeping on it too, and that does usually work, but not this time). :)

December 24, 2011 at 9:30 am #2231

CyberGreg
@implementation CCZLabelBMFont
-(void) draw
{
	glEnable(GL_ALPHA_TEST);
	glAlphaFunc(GL_GREATER, 0.0f);
	[super draw];
	glDisable(GL_ALPHA_TEST);
}
@end

Just like CCZSprite ;-)
This is from the Cocos2d 0.99.5 version; might need to be updated

December 25, 2011 at 8:42 pm #2234

Pete

Haha – thanks, I thought it must’ve changed. I’ll take another look, at least I can eliminate that now – cheers.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.