Saturday, November 17, 2012

AWTextureFilter的應用

        tex = [[CCTexture2DMutable alloc] initWithImage:
                                    [UIImage imageNamed:@"Default.png"]];
        
        ccColor4B color = ccc4(0,0,0,0); // [1].這裡的a值必須為0
        //ccColor4B color = ccc4(221, 108, 20, 0);
        [tex fill:color]; // ***NOTE***: It seems that this affect blur function
               
        
        [tex setAliasTexParameters];
                
        [tex autorelease];
        
        // disable texture filtering (no smoothing, clear and crisp pixels)
        sprite = [CCSprite spriteWithTexture:tex];
        sprite.anchorPoint = ccp(0, 1);
        
        // add label
        [sprite addChild: msg];
        [tex apply];


              tex = [AWTextureFilter blur:tex radius:24 rect:rect];

一點值得注意, [1]的a值必須為0,而且color的值決定了陰影的色彩.