DrawNode setOpacity doesn't work

I have this

this->mDrawNode =DrawNode::create();
this->mDrawNode->retain();
this->mNode->addChild(this->mDrawNode,0,MAP_DRAWNODE_TAG);

this->mDrawNode->drawSegment(Vec2(p1.x,p1.y), Vec2(p2.x,p2.y), 3, this->mDrawNodeColor);

… blablabla

-> all is ok color… opacity (1 in this case)… segment

void CEffect::Update(float dt)
{

this->mDrawNode->setOpacity(128); // opacity doesn’t change

}
i tried
this->mNode->setCascadeOpacityEnabled(true);
this->mDrawNode->setCascadeOpacityEnabled(true);
-> it changes nothing

Impossible to make a fade effect on my drawing node…
What I’m missing?

Any idea?

please help :slight_smile:

Please Reply, I’m wasting a lot of time on something who is perhaps “normal”
Can we change the color or a opacity of a drawing node in a the update with a different value of its parent? In my case it doesn’t work, so what I missing?

Sorry for my poor english.

It looks the same problem I Have

Hello @fabrice, i have a solution, look my code

rectWithBorder = DrawNode::create();
    Vec2 vertices[] =
    {
        Vec2(origin.x,origin.y),
        Vec2(origin.x,visibleSize.height),
        Vec2((origin.x - visibleSize.width/2),visibleSize.height),
        Vec2((origin.x - visibleSize.width/2),origin.y)
    };
    rectWithBorder->drawPolygon(vertices, 4,Color4F(0.2f,0.2f,0.2f,0.5), 0, Color4F(0.2f,0.2f,0.2f,1));
    this->addChild(rectWithBorder,7);

Especially this line
rectWithBorder->drawPolygon(vertices, 4,Color4F(0.2f,0.2f,0.2f,0.5), 0, Color4F(0.2f,0.2f,0.2f,1));

for Color4F(r,g,b,a), i put 0.5 to get alpha opacity and its working, i hope this work for you (sorry for my bad english)

1 Like

It should be fixed with https://github.com/cocos2d/cocos2d-x/pull/17248

At what version of the engine It should work?
I tested with 3-13 and it doesen’t work…

3.15 supposedly. https://github.com/cocos2d/cocos2d-x/blob/v3/CHANGELOG line 43 at this point in time.

Cool! Thanks! A will use it soon =)