The screen class represents the area of the screen that an Applet can draw on.
This native object is passed into the constructor of an applet when the applet is instantiated. It's purpose is to give the applet access to important native functionality. Note that a script applet cannot directly draw something. Every drawing is done by the system. The applet usually creates one or more Layer objects and attaches them to the screen using AddLayer(). The script can then manipulate properties of the layers to, for example move the layer or animate it.
|AddLayer (Layer)||Adds a new layer to the screen.|
|BackColor (Color)||Sets the screens background color.|
|Caption (string)||Sets the main window caption to the specified string.|
|FixedSize (int, int)||Tells the system that it should keep the window size fixed.|
|FullScreen (int, int, int)||Tries to enter fullscreen mode using the given resolution.|
|int GetCurrentFPS ()||Returns the fps rate that the system currently makes.|
|Point GetMouse ()||Returns the current mouse position.|
|int GetPadState (int)||Returns the state of the specified button of a gamepad.|
|int Height ()||Returns the height of the screen.|
|Layer LayerAt (int, int)||Finds and returns the first layer that occupies the specified point on the screen.|
|int LayerCollision (Layer, Screen::OnCollide)||Finds all layers that overlap (collide) with the specified layer.|
|MoveToBack (Layer)||Moves the specified layer to the bottom of the z-order.|
|MoveToFront (Layer)||Moves the specified layer to the top of the z-order.|
|int NumLayers ()||Returns the number of layers currently added to the screen.|
|Offset (int, int)||Defines a global offset that will be applied to all layers.|
|Redraw ()||Posts a redraw event to the system.|
|RemoveAllLayers ()||Removes all layers currently in the screen's list of layers.|
|RemoveLayer (Layer)||Removes a layer from the screen.|
|SetDesiredFPS (int)||Tries to match the specified frames per second.|
|SetIdleTime (int)||Specifies the number of millisecond the system thread is allowed to idle.|
|SetSize (int, int)||Resizes the main window to the specified size.|
|int Width ()||Returns the width of the screen.|
|WriteLog (string)||Writes the specified string into the log.|
method AddLayer (Layer layer)
Adds a new layer to the screen.
Only layers added to the screen can be drawn or taken into account by LayerCollision(). By default, the system draws layers in the same order in which they were added. So the last added layer will appear on top of all others. You can use MoveToFront() or MoveToBack() to change the z-order of a layer anytime.
method BackColor (Color)
Sets the screens background color.
method Caption (string title)
Sets the main window caption to the specified string.
method FixedSize (int w, int h)
Tells the system that it should keep the window size fixed.
If you call this, it should be called from within the constructor of your Applet.
method FullScreen (int width, int height, int sync)
Tries to enter fullscreen mode using the given resolution.
If 'sync' is set to true, tries to sync to avoid tearing and flickering. Currently not recommended. Use with caution.
method int GetCurrentFPS ()
Returns the fps rate that the system currently makes.
The result of this function is only an approximation and only valid if you have called SetDesiredFPS() before.
method Point GetMouse ()
Returns the current mouse position.
method int GetPadState (int button)
Returns the state of the specified button of a gamepad.
Returns true if the button is pressed, false if not. Valid button IDs are kPadUp, kPadDown, kPadLeft, kPadRight, kPadButton1, kPadButton2.
method int Height ()
Returns the height of the screen.
method Layer LayerAt (int x, int y)
Finds and returns the first layer that occupies the specified point on the screen.
If no layer is found, null is returned, so you should make sure you check the result before accessing any layer properties. Layer objects that have been hidden by Layer::Hide() will not be taken into account.
method int LayerCollision (Layer, Screen::OnCollide)
Finds all layers that overlap (collide) with the specified layer.
This method will call the specified delegate for every layer that currently overlaps with the specified layer. The delegate can be a method in your applet class, see Screen::OnCollide().
method MoveToBack (Layer layer)
Moves the specified layer to the bottom of the z-order.
method MoveToFront (Layer layer)
Moves the specified layer to the top of the z-order.
The layer must be added to the screen, obviously.
method int NumLayers ()
Returns the number of layers currently added to the screen.
method Offset (int dx, int dy)
Defines a global offset that will be applied to all layers.
You can 'scroll' your layers through the screen that way.
method Redraw ()
Posts a redraw event to the system.
Any changes to the screen will not be visible until this event was posted. Typically an applet posts this event at the end of Idle(), but it can be posted from any function.
method RemoveAllLayers ()
Removes all layers currently in the screen's list of layers.
method RemoveLayer (Layer layer)
Removes a layer from the screen.
method SetDesiredFPS (int fps)
Tries to match the specified frames per second.
If you call this, the system will try to time calls to Idle() so that the specified number of fps are met. Obviously, if you set this higher than your system is capable, the actual fps rate will be lower.
method SetIdleTime (int msec)
Specifies the number of millisecond the system thread is allowed to idle.
Default is 20 ms. Using lower values will allow more fluid animations, but also increase CPU demand.
method SetSize (int w, int h)
Resizes the main window to the specified size.
If you call this, it should be called from the constructor of your Applet.
method int Width ()
Returns the width of the screen.
method WriteLog (string text)
Writes the specified string into the log.
If logging is not enabled, the string goes nowhere. Logging can be enabled using command line options.