Class l2df.manager.render

Last updated 2021-05-28 15:24:22

Render manager.

Info:

Functions

Manager:init([kwargs]) Configure RenderManager.
Manager:resize(width, height) Resizes screen with specified width and height.
Manager:setResolution(width, height, depth) Set up game space.
Manager:addLayer(name[, kwargs]) Add new layer for drawings.
Manager:updateLayerWorld(name[, width[, height[, depth[, zoom=1]]]]) Update world dimensions for specified layer.
Manager:removeLayer(name) Remove layer with specified name.
Manager:track(layer[, x[, y[, ox=0[, oy=0[, kx=0[, ky=0[, priority=1]]]]]]]) Request layer's camera to track specific point.
Manager:addLight(light) Add new light source.
Manager:draw(element) Push element to render chain.
Manager:clear() Clear all layers, render chain, trackers and reset cameras.
Manager:render() Render all added drawables depepending on their type.

Tables

Layer Layer is an internal object used by renderer for sorting-out drawables order.
Light Light's table description.
RenderObject Table containing information used for rendering.

Fields

Manager.width Width of the visible area in the game world.
Manager.height Height of the visible area in the game world.
Manager.depth Default depth of game worlds.


Functions

Methods
Manager:init([kwargs])
Configure RenderManager.

Parameters:

  • kwargs table
                    Table containing all settings parameters.
    
    • width number
           Width of the game in pixels. It's independent from the width of the screen / window.
      
      (default 640)
    • height number
          Height of the game in pixels. It's independent from the height of the screen / window.
      
      (default 360)
    • depth number
             Default depth of worlds. Required for correct z-ordering.
      
      (default 1)
    • cellsize number
          Size of the one depth cell in pixels. Required for correct z-ordering.
      
      (default 1)
    • shadows number
           Quality of shadows (number from 0 to 2).
      
      (default 2)
    • filter string Filter to use for up/downscaling textures. Can be 'nearest' or 'linear'. (default 'nearest')
    • ratio boolean
              Set to true to keep game's aspect ratio and have black borders if it doesn't match current window size.
      
      (optional)
    • fullscreen boolean
         Set to true to use fullscreen mode.
      
      (optional)
    • resizable boolean
          Set to true to allow user manually resize game window.
      
      (optional)
    • vsync boolean
              Set to true to use vertical synchronization.
      
      (optional)

Returns:

    l2df.manager.render
Manager:resize(width, height)
Resizes screen with specified width and height.

Parameters:

  • width number Screen width. Note that it is not the same as game width.
  • height number Screen height. Note that it is not the same as game height.
Manager:setResolution(width, height, depth)
Set up game space. Updates RenderManager.width and RenderManager.height.

Parameters:

  • width number Width of the game. It's independent from the width of the screen / window.
  • height number Height of the game. It's independent from the height of the screen / window.
  • depth number Default depth of the worlds. Required for correct z-ordering.
Manager:addLayer(name[, kwargs])
Add new layer for drawings.

Parameters:

  • name string Layer's name. Should be unique for each layer.
  • kwargs table Keyword arguments containing layer values.
    • x number Layer X position in window space. Used when layer has no camera. (default 0)
    • y number Layer Y position in window space. Used when layer has no camera. (default 0)
    • width number Layer world width. Used when layer has no camera. Defaults to RenderManager.width. (optional)
    • height number Layer world height. Used when layer has no camera. Defaults to RenderManager.height. (optional)
    • depth number Used for Z-ordering of added drawables. Defaults to RenderManager.depth. (optional)
    • index number Index used for sorting layers. Auto-increments for each added layer if not set properly. (default 1)
    • background {number,number,number,number} RGBA color. Each component must be in range [0; 255]. Default to white non-transparent color. (optional)
    • camera boolean True if layer should create its own camera. False otherwise. (default false)
Manager:updateLayerWorld(name[, width[, height[, depth[, zoom=1]]]])
Update world dimensions for specified layer.

Parameters:

  • name string Layer's name. Should be unique for each layer.
  • width number Width of the world. (optional)
  • height number Height of the world. (optional)
  • depth number Depth of the world. Required for correct Z-ordering. (optional)
  • zoom number Update camera default zoom (when no points are tracked). (default 1)
Manager:removeLayer(name)
Remove layer with specified name.

Parameters:

  • name string Layer's name. Should be unique for each layer.
Manager:track(layer[, x[, y[, ox=0[, oy=0[, kx=0[, ky=0[, priority=1]]]]]]])
Request layer's camera to track specific point.

Parameters:

  • layer string Layer's name which has camera attached.
  • x number X position of the tracked point. (optional)
  • y number Y position of the tracked point. (optional)
  • ox number Offset 1 X. (default 0)
  • oy number Offset 1 Y. (default 0)
  • kx number Offset 2 X. (default 0)
  • ky number Offset 2 Y. (default 0)
  • priority number Priority of this point in favor of other tracked by that camera points. (default 1)
Manager:addLight(light)
Add new light source. Lights are used for shadows rendering. Note that all added lights are cleared with each RenderManager:clear() call.

Parameters:

Manager:draw(element)
Push element to render chain.

Parameters:

Manager:clear()
Clear all layers, render chain, trackers and reset cameras.
Manager:render()
Render all added drawables depepending on their type.

Tables

Layer
Layer is an internal object used by renderer for sorting-out drawables order. There are several methods to control layers: addLayer, removeLayer, updateLayerWorld, track and clear. Could be generated by CollisionComponent:collider().
Light
Light's table description.

Fields:

  • x number X position in the game world space.
  • y number Y position in the game world space.
  • z number Z position in the game world space.
  • r number Maximum radius (point light).
  • f number Light's force, also known as "intensity".
RenderObject
Table containing information used for rendering. Currently undocumented.

Fields

Manager.width number
Width of the visible area in the game world.
Manager.height number
Height of the visible area in the game world.
Manager.depth number
Default depth of game worlds. Used for z-ordering.