Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

DirectionalLight2D

繼承: Light2D < Node2D < CanvasItem < Node < Object

來自遠處的 2D 平行光。

說明

A directional light is a type of Light2D node that models an infinite number of parallel rays covering the entire scene. It is used for lights with strong intensity that are located far away from the scene (for example: to model sunlight or moonlight).

Light is emitted in the +Y direction of the node's global basis. For an unrotated light, this means that the light is emitted downwards. The position of the node is ignored; only the basis is used to determine light direction.

Note: DirectionalLight2D does not support light cull masks (but it supports shadow cull masks). It will always light up 2D nodes, regardless of the 2D node's CanvasItem.light_mask.

教學

屬性

float

height

0.0

float

max_distance

10000.0


屬性說明

float height = 0.0 🔗

  • void set_height(value: float)

  • float get_height()

燈光的高度。用於 2D 法線貼圖。範圍從 0(平行於平面)到 1(垂直於平面)。


float max_distance = 10000.0 🔗

  • void set_max_distance(value: float)

  • float get_max_distance()

物件在其陰影被剔除前與相機中心的最大距離(單位:圖元)。降低這個值可以防止位於相機外部的物件投射陰影(同時還可以提高性能)。Camera2D.zoom 不被 max_distance 考慮在內,這意味著在較高的縮放值下,當縮放到一個給定的點時,陰影會更快地淡出。