Light2D

Inherits: Node2D < CanvasItem < Node < Object

Category: Core

Brief Description

Node that casts light in a 2D environment.

Member Functions

Color get_color ( ) const
float get_energy ( ) const
float get_height ( ) const
int get_item_mask ( ) const
int get_item_shadow_mask ( ) const
int get_layer_range_max ( ) const
int get_layer_range_min ( ) const
int get_mode ( ) const
int get_shadow_buffer_size ( ) const
Color get_shadow_color ( ) const
float get_shadow_esm_multiplier ( ) const
Object get_texture ( ) const
Vector2 get_texture_offset ( ) const
float get_texture_scale ( ) const
int get_z_range_max ( ) const
int get_z_range_min ( ) const
bool is_enabled ( ) const
bool is_shadow_enabled ( ) const
void set_color ( Color color )
void set_enabled ( bool enabled )
void set_energy ( float energy )
void set_height ( float height )
void set_item_mask ( int item_mask )
void set_item_shadow_mask ( int item_shadow_mask )
void set_layer_range_max ( int layer )
void set_layer_range_min ( int layer )
void set_mode ( int mode )
void set_shadow_buffer_size ( int size )
void set_shadow_color ( Color shadow_color )
void set_shadow_enabled ( bool enabled )
void set_shadow_esm_multiplier ( float multiplier )
void set_texture ( Object texture )
void set_texture_offset ( Vector2 texture_offset )
void set_texture_scale ( float texture_scale )
void set_z_range_max ( int z )
void set_z_range_min ( int z )

Numeric Constants

  • MODE_ADD = 0 — Adds the value of pixels corresponding to the Light2D to the values of pixels under it. This is the common behaviour of a light.
  • MODE_SUB = 1 — Substract the value of pixels corresponding to the Light2D to the values of pixels under it, resulting in inversed light effect.
  • MODE_MIX = 2 — Mix the value of pixels corresponding to the Light2D to the values of pixels under it by linear interpolation.
  • MODE_MASK = 3 — The light texture of the Light2D is used as a mask, hiding or revealing parts of the screen underneath depending on the value of each pixel of the light (mask) texture.

Description

Node that casts light in a 2D environment. Light is defined by a (usually grayscale) texture, a color, an energy value, a mode (see constants), and various other parameters (range and shadows-related). Note that Light2D can be used as a mask.

Member Function Description

  • Color get_color ( ) const

Return the color of the Light2D.

  • float get_energy ( ) const

Return the energy value of the Light2D.

  • float get_height ( ) const

Return the height of the Light2D. Used with 2D normalmapping.

  • int get_item_mask ( ) const

Return the item mask of the Light2D.

  • int get_item_shadow_mask ( ) const

Return the item shadow mask of the Light2D.

  • int get_layer_range_max ( ) const

Set the maximum layer value of objects of the scene that are affected by the Light2D.

  • int get_layer_range_min ( ) const

Get the minimum layer value of objects of the scene that are affected by the Light2D.

  • int get_mode ( ) const

Return the current mode set to the Light2D.

  • int get_shadow_buffer_size ( ) const

Return the shadow buffer size.

  • Color get_shadow_color ( ) const

Return the color of casted shadows for this Light2D.

  • float get_shadow_esm_multiplier ( ) const

Return the Exponential Shadow Multiplier (ESM) value of the Light2D.

  • Object get_texture ( ) const

Return the texture of the Light2D.

  • Vector2 get_texture_offset ( ) const

Return the offset of the light texture.

  • float get_texture_scale ( ) const

Return the scale value of the light texture.

  • int get_z_range_max ( ) const

Get the maximum Z value that objects of the scene can be in order to be affected by the Light2D.

  • int get_z_range_min ( ) const

Get the minimum Z value that objects of the scene have to be in order to be affected by the Light2D.

  • bool is_enabled ( ) const

Return true if the Light2D is enabled, false if it is not.

  • bool is_shadow_enabled ( ) const

Return true if shadow casting is enabled for this Light2D, else return false.

  • void set_color ( Color color )

Set the color of the Light2D.

  • void set_enabled ( bool enabled )

Switches the Light2D on or off, depending on the ‘enabled’ parameter.

  • void set_energy ( float energy )

Set the energy value of the Light2D. The bigger the value, the stronger the light.

  • void set_height ( float height )

Set the height of the Light2D. Used with 2D normalmapping.

  • void set_item_mask ( int item_mask )

Set the item mask of the Light2D to ‘item_mask’ value.

  • void set_item_shadow_mask ( int item_shadow_mask )

Set the item shadow mask to ‘item_shadow_mask’ value.

  • void set_layer_range_max ( int layer )

Set the maximum layer value of objects of the scene that are affected by the Light2D.

  • void set_layer_range_min ( int layer )

Set the minimum layer value of objects of the scene that are affected by the Light2D.

  • void set_mode ( int mode )

Set the behaviour mode of the Light2D. Use constants defined in the constants section.

  • void set_shadow_buffer_size ( int size )

Set the shadow buffer size.

  • void set_shadow_color ( Color shadow_color )

Set the color of casted shadows for this Light2D.

  • void set_shadow_enabled ( bool enabled )

Enable or disable shadows casting from this Light2D according to the ‘enabled’ parameter.

  • void set_shadow_esm_multiplier ( float multiplier )

Set the Exponential Shadow Multiplier (ESM) value of the Light2D.

  • void set_texture ( Object texture )

Set the texture of the Light2D.

  • void set_texture_offset ( Vector2 texture_offset )

Set the offset of the light texture.

  • void set_texture_scale ( float texture_scale )

Set the scale value of the light texture.

  • void set_z_range_max ( int z )

Set the maximum Z value that objects of the scene can be in order to be affected by the Light2D.

  • void set_z_range_min ( int z )

Set the minimum Z value that objects of the scene have to be in order to be affected by the Light2D.