Change scene backgroundcolor with globalvariable

Hey, im not familiar yet with all the commands in gdevelop, so i need a hand here.
I want either to add 1 every x seconds to a global variable, to set the background color every x seconds/every tick, or lerp. Is there a function like rgb(“globalvariable”,“globalvariable”,“globalvariable”) which i can use to do so ? Im only using the default layerbackground color, no background sprite, so its important to change color that way, because im to stupid to get wrap working.

Ok i might found a solution, but it doesnt seem to be working:

Reapet timer “” every 0.1 seconds > change global variable BGcolor: +=1
>Change the background color of the scene > color: “0;0;GlobalVariable(BGColor)”

Any ideas?

If you want to just change the background tint and not save it to a variable you can use ToString to randomize the colors.


Link Third Whip | Play on



Is it what you wrote in the editor?

The change background colour event accepts a string, so you should have writen

To have the 3 colors :

1 Like

Thanks for your response, i want it to go from black to blue, thats why i made a variable to add x to it every x seconds, so the color would become “0;0;255”

Ye i actually missed the extra " and + there.

But one more question, does the variable has to be a number or string? im confused

It’s more convinient that your colour variables are numbers.

But if you use GlobalVariableString(x) with a variable x that is a number, GDevelop will automatically write it as a string.

So to summarize :

  • the colour variables will be numbers : Variable(colour) =18
  • In the background colour event, it is needed a string, as I wrote your in the previous reply. So you will use VariableString(colour) and this will become, for the computer, “18”, a string.
1 Like

Variables or global variables, whatever you choose, will work like that.

1 Like

Finaly its working, i mean i do understand what you are talking about, but its hard coming from construct to rethink about it. I dont know what i now changed to get it working, because i had ToString(globalvariable(bgcolor)) before and it didnt work. But both GlobalVariableString(bgcolor) and ToString(globalvariable(bgcolor)) working now.

Thank you so much for your time !

1 Like

You’re welcome!

I don’t know about that. When I started using Gdevelop I used to make a lot of mistakes, like forgetting a letter, a capital letter, an endless loop, etc. Btw GDevelop is case sensitive. Now that I’m used to it I don’t loose time anymore on this kind of mistakes.

Yes the case sensitivity actually is annoying to me, makes my “workflow” much slower :confused: but i might get used to used to it. All the community plugins, built in assets and sfxr made me try gdevelop. Lets see what happens in the future :stuck_out_tongue:

Thanks again for the help!

1 Like