FANDOM


cls( [color] )

Clears the graphics buffer.

color
(Undocumented.) A color to use for the background. The default is 0 (black).

The cls() function clears the graphics buffer, effectively setting every pixel to the color 0. If the color argument is provided, that number is used instead. (The color argument is not mentioned in the documentation.)

cls() also sets the text cursor in the draw state to (0, 0).

This ignores the alternate palette set by pal() for the purposes of using color 0. (pal(0, 7) cls() does not fill the screen with white.) To fill the screen with a specific color, use rectfill.

It is common (though not required) to call cls() at the beginning of the _draw() function as part of the game loop.

Examples Edit

function _init()
  x = 0
end

function _update()
  -- add 1 to x. if x > 128, reset it to 0.
  x = (x + 1) % 128
end

function _draw()
  cls()
  circfill(x, x, 10, 8)
end

Try removing the cls() call from this example.

Cls example

See also Edit

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.