The global object "display" represents the game window. It is used to set the resolution and display mode. The display object is also used for rendering on the screen. For example, you can add layers and sprites as child nodes to the default viewport object found in display. This draws sprites without any transformation so their positions remain relative to the center of the window.

Another way of rendering a scene is by using cameras. First, the camera is inserted as a child node to one of the layers in the scene. Then, the camera is assigned to the default viewport object. From that point onward, the viewport will render the part of the scene where the camera is located.

Figure 1: An example scene for a scrolling game. The default camera is inserted in the level scene. The player HUD (heads-up display) and UI (user interface) are overlaid on top.

The display object also broadcasts notifications raised by the operating system. There are notifications for different system events such as the application window losing focus or being closed. Typically, you'll be writing handler functions that react to these events by pausing the gameplay, saving the user's progress and so forth.