background Color

Get the background color of the screen.


You can get the background color of the screen anytime. The background color is always behind other images shown on the screen.


  • a number which is the the color set as the screen background color.


Show a purple square on the screen. Every second, switch the background color between light and dark.

let showSquare: Sprite = null
let purpleSquare: Image = null
let toggle = false
toggle = true
purpleSquare = image.create(32, 32)
showSquare = sprites.create(purpleSquare)
game.onUpdateInterval(1000, function () {
    scene.setBackgroundColor((scene.backgroundColor() + 1) % 2) //toggle between 0 and 1


See also

set background color