![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | anbarasu chinna |
I have created a simple shooting game. Mid of the game, player can level up automatically. To give better user experience on level up I tried to change the background color of ColorRect with following code.
extends ColorRect
var totalTime = 0
var endTime = 25
func _process(delta):
if Globals.State == Globals.GameState.Running:
totalTime += delta
if totalTime > endTime:
totalTime = 0
randomize()
var r = rand_range(50, 200) / 255
var g = rand_range(50, 200) / 255
var b = rand_range(50, 200) / 255
set_frame_color(Color(r,g,b,1))
This code working fine and changing color of the ColorRect instantly. I do not want the instant color changing behavior. I want the color should be changed smoothly over time with animation.
How to achieve this.
Thanks in advance.