cocos2d的。正确混合?

时间:2013-03-18 13:06:01

标签: cocos2d-iphone blend blending glblendfunc

我修改了标准示例“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];

我得到了:

image enter image description here

如何删除/剪切“Hello World”标签周围的背景?

1 个答案:

答案 0 :(得分:3)

我目前的解决方案是初始化CCLabelTTF:

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

其中size是[CCDirector sharedDirector] .winSize for my examle。

欢迎任何其他建议