Skip to content
Download

Rooms and window

Function What it does
goTo(name) Switches to the room with that name, at the end of the frame.
fadeTo(name, seconds, color) Switches rooms with a fade. Defaults: 0.6 s and black.
restart() Recreates the current room, at the end of the frame.
roomWidth(), roomHeight() Size of the current room, in pixels.
roomName() Lua: the name of the current room.
if count("Enemy") == 0 then fadeTo("Fase2") end
if self.y > roomHeight() then restart() end
Function What it does
setPaused(on) Pauses or resumes the game. While paused, instances do not run timers, onUpdate, movement or collision; onPausedUpdate runs.
paused() true if the game is paused.
flash(color, seconds) Covers the screen with a color that fades over the given time. Defaults: white and 0.2 s.
quit() Closes the game at the end of the frame.
function onUpdate(self)
if pressed("pausa") then
setPaused(true)
Ui.show("Pausa")
end
end
function onPausedUpdate(self)
if pressed("pausa") then
setPaused(false)
Ui.hide("Pausa")
end
end

For a video options menu. Project settings only define the initial value.

Function What it does
Window.setFullscreen(on), Window.fullscreen() Fullscreen.
Window.setScale(mode), Window.scale() How the image is scaled: integer, fit or stretch.
Window.setSize(width, height) Window size, in screen pixels. The game resolution does not change.
Window.width(), Window.height() Current window size.
Window.screenWidth(), Window.screenHeight() Monitor size.
Window.setFullscreen(not Window.fullscreen())
Window.setScale("fit")
  • On a room change, the instances of the current room are destroyed, except the persistent ones. Changing rooms clears the pause.
  • A room name that does not exist is reported in the Output and ignored.
  • The initial room is defined in Project settings.
  • C++: outside an object, use brasa::goToScene("Name"). The scale modes are WindowScale::Integer, Fit and Stretch; in Lua, "integer", "fit" and "stretch".