5

I modified standard example "Hello World":

        CCSprite *sprite = [CCSprite spriteWithFile:@"Untitled-1.png"];
        CGSize winSize = [CCDirector sharedDirector].winSize;
        sprite.position = ccp(winSize.width / 2, winSize.height / 2);
        [label setBlendFunc:(ccBlendFunc){GL_ZERO, GL_SRC_ALPHA}];
        [label setColor:ccBLACK];
        [sprite addChild:label];
        [self addChild:sprite];

I got:

image enter image description here

How to delete/cut a background around "Hello World" label?

Guru
  • 21,652
  • 10
  • 63
  • 102
user2083364
  • 744
  • 1
  • 7
  • 20
  • what are you trying to achieve? with {GL_ZERO, GL_SRC_ALPHA} you multiply background color by source alpha and don't draw source color at all, which results in black color where source alpha was 0 and background color where source was opaque. – Kreiri Mar 19 '13 at 09:27
  • 2
    I want to get a gradient font and I can't allow myself to buy something like glyph Editor. – user2083364 Mar 28 '13 at 16:38

1 Answers1

3

my current solution is to init CCLabelTTF something like this:

CCLabelTTF *label = [CCLabelTTF labelWithString:@"Hello World" fontName:@"Marker Felt" fontSize:64 dimensions:size hAlignment:kCCTextAlignmentCenter vAlignment:kCCVerticalTextAlignmentCenter];

where size is [CCDirector sharedDirector].winSize for my examle.

any other suggestions are welcome

user2083364
  • 744
  • 1
  • 7
  • 20
  • this solution works perfect for 2 layers only, but erases the third and other layers. It means that area around the label is black, not transparent – user2083364 Jun 12 '13 at 06:52