Fade In and Out

Hello,
Is it possible to do fading effect (fade in and out) using cocos creator v3.4.1?
tween is not accepting alpha or color as target.
I just wanted to do this.node.active slowly.

I tried this :

this.node.runAction(cc.sequence( 
    cc.fadeOut(), 
    cc.callFunc(function () {
         cc.director.loadScene('xxx');
    })
));

but it gives error
Property 'runAction' does not exist on type 'Node'.

You can use tween to change color like this:
tween(this.sp).to(0.5,{color:new Color(255,255,255,255)}).delay(2).to(0.5,{color:new Color(255,255,255,0)}).start()
dont use runAction.

I get this error if I try your method.

Is it possible to call a set of code n number of times within certain sec?
For Example :

this.node.color = new Color (255, 255, 255, opactyInc);
opactyInc += 1;

The above code must run 255 times within 0.5 sec.

Tried tween but it gives error.


I used the same code and no errors were reported, but I found that there are still bugs in changing the color value now, which we will fix in 3.6.
I updated the colors with update and it works fine.



You can use UIOpacity to change opacity.

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.