Cocos Creator 3.4.0 Tween color alpha strange behaviour

Hi all, I am trying to tween colour alpha property, but getting this result?
Why it changes a lot of colours if I just use black colour to tween? Thanks.

		tween(this.sprite)
			.to(3.15, { color: new Color(0, 0, 0, 150) })
			.start();

		tween(this.sprite)
			.to(3.15, { color: new Color(0, 0, 0, 0) })
			.start();

I can ask engineering to have a look.

Since you are using the to property in the tween, the meaning of ‘to’ from the above code is to change the color to (0, 0,0, 150) in 3.15 seconds, then the color will move closer and closer to the target value from the initial value in 3.15 seconds, reaching the target value in 3.15 seconds. Therefore, there will be a situation like the video, where the color keeps changing and finally becomes black.
If you want the picture to become what you want in a flash, you can set it like this.
this.spr.color = new Color(0,0,0,150);

Translated with www.DeepL.com/Translator (free version)

But my initial color is 0, 0, 0, 0 (black and full alpha)
so it should just change alpha property? I mean when I tween position Vector (0, 0, 0) to Vector (150, 0, 0) it will tween just x position… so/

I need smooth animation. I remember Cocos recommends to change Color property instead of add UIOpacity component and tween opacity property of it.

If you are trying to change its alpha value. then it is UIOpacity that should be used to make the change. Instead of using color

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