Skip to content
paul59 edited this page Dec 20, 2019 · 16 revisions

cls

cls[color]

Parameters:

  • color : the index (0 to 15) of the color in the current palette.

Description:

When called this function clears the entire screen using the color passed as argument.
If no parameter is passed first color (index 0) is used.

This is usually called inside the TIC() function, but it's not mandatory. You can make some interesting effects by not calling it or using it to "flash" the screen when some special event occurs. If you are drawing to the entire screen (for example with sprites, the map or primitive shapes), there is no need to clear the screen with cls() beforehand.

Tip: Use a color over 15 to see some interesting fill patterns!

Example:

Example

-- cls demo
c=0
function TIC()
	--Use Up/Down to change color
	if btnp(0) then c=c+1 end
	if btnp(1) then c=c-1 end

	--Clear with the color 
	cls(c)
	
	--Make a background for the text 
	rect(0,0,240,8,0)
	--Ouput a text with function call
	print('cls('..c..')  --Use Up/Down to change color')
end
Clone this wiki locally