Bogdan
Bogdan

Reputation: 399

Cocos2d spriteframe transparent background

I am creating a vector of spriteframes but I don't know how to set the opacity of the background of said frames. Here's my code:

for (int i = 1; i <= 2; i++)
    {
        sprintf(str, "idle%i.png", i);
        auto frame = SpriteFrame::create(str, Rect(0, 0, 26, 32));
        idleFrames.pushBack(frame);
    }

    auto idleAnimation = Animation::createWithSpriteFrames(idleFrames, 0.20f);
    idlingAnim = Animate::create(idleAnimation);
    idlingAnim->retain();
    this->runAction(RepeatForever::create(idlingAnim));

I'm new at cocos2d and I don't know if this is exactly the right way to do it. Can anyone tell me how to set the background opacity of the frames?

This is what happens at the moment: https://i.sstatic.net/ncr05.png

Upvotes: 0

Views: 358

Answers (1)

Suratraak
Suratraak

Reputation: 148

Use any Image editor such as GIMP, Photoshop to edit the image. Cocos change entire the image's opacity, not only background. (You may achieve that by coding shaders but it is very hard).

Upvotes: 2

Related Questions