Solarus quests  1.5
Quest maker's reference
Surfaces

A surface is a 2D image. It is essentially a rectangle of pixels. Its main feature is that you can draw objects on it.

Functions of sol.surface

sol.surface.create([width, height])

Creates an empty surface.

  • width (number, optional): Width of the surface to create in pixels. The default value is the width of the logical screen.
  • height (number, optional): Height of the surface to create in pixels. The default value is the height of the logical screen.
  • Return value (surface): The surface created.

sol.surface.create(file_name, [language_specific])

Creates a surface from an image file.

  • file_name (string): Name of the image file to load.
  • language_specific (boolean, optional): true to load the image from the images subdirectory of the current language directory (default is false and loads the image from the sprites directory).
  • Return value (surface): The surface created, or nil if the image file could not be loaded.

Methods inherited from drawable

Surfaces are particular drawable objects. Therefore, they inherit all methods from the type drawable.

See Methods of all drawable types to know these methods.

Methods of the type surface

The following methods are specific to surfaces.

surface:get_size()

Returns the size of this surface.

  • Return value 1 (number): Width of the surface in pixels.
  • Return value 2 (number): Height of the surface in pixels.

surface:clear()

Erases all pixels of this surface.

All pixels become transparent. The opacity property and the size of the surface are preserved.

surface:fill_color(color, [x, y, width, height])

Fills a region of this surface with a color.

If no region is specified, the entire surface is filled. If the color has an alpha component different from 255 (opaque), then the color is blended onto the existing pixels.

  • color (table): The color as an array of 3 RGB values or 4 RGBA values (0 to 255).
  • x (number, optional): X coordinate of the region to fill on this surface.
  • y (number, optional): Y coordinate of the region to fill on this surface.
  • width (number, optional): Width of the region to fill on this surface.
  • height (number, optional): Height of the region to fill on this surface.

surface:get_opacity()

Returns the opacity of this surface.

  • Return value (integer): The opacity: 0 (transparent) to 255 (opaque).

surface:set_opacity(opacity)

Sets the opacity of this surface.

All surfaces are initially opaque.

  • opacity (integer): The opacity: 0 (transparent) to 255 (opaque).