Interpolate Colors?
SikkJewFro
Member Posts: 75
in Help Wanted
Im trying to get a sky-time effect, meaning, I want my "Sky" actor which by default is set to a light blue, to slowly progress to a dark black (night) color, and then at that point, progress back to blue, Is there any way I can make this happen?
I realize I would need a timer set to roughly every 0.2 seconds change its color, but I can't tell it to set its self.color.red to -1 because that would set it immedietly to -1, I just want it to subtract its Red number (In RGB) by 1 every 0.2 seconds, I would appreciate the help!
Comments
Hi @SikkJewFro you answered your own question in your thread title with the word Interpolate - so you can use that behaviour to get the result you're after (this has a time factor built into it).
To point out, the RGB colours in GSC are between the ranges of 0 and 1 so (apart from little "tricks" to input 0 to 255 values) you use fractions of 1.
So try something like this (however many minutes changed to seconds in the time part; for this example I'm using 10 minutes) start setting self.Red to 0, Green as something like .75, Blue as 1 (straightforward way to get darker and darker blue and finally to black, then back again, repeating):
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
You might need to do it in stages. Moving between intermediary colors. Basically interpolating to say five color schemes.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
The most straightforward way would be to create an actor, change its colour to blue, then fade it in and out by interpolating its alpha channel.
You could even constrain its opacity to a sine wave so it oscillates back and forth between 0 and 1 at whatever speed you need.
@SikkJewFro
@Socks way is the better way to go! Very straightforward: make sure your background behind the sky actor is black, then in the blue sky actor:
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Whoops, yep, forgot to mention that, like you say the background will need to be black.
These are the values you would use if you wanted it to oscillate back and forth between blue and black (or blue and transparent), constrain the alpha channel to . . .
0.5*sin(game.Time *20)+0.5
('20' is the speed).