PokéRogue
    Preparing search index...

    A 2D Light.

    These are created by the Phaser.GameObjects.LightsManager, available from within a scene via this.lights.

    Any Game Objects with the Lighting Component, and setLighting(true), will then be affected by these Lights. If they have a normal map, it will be used. If they don't, the Lights will use the default normal map, a flat surface.

    They can also simply be used to represent a point light for your own purposes.

    Lights cannot be added to Containers. They are designed to exist in the root of a Scene.

    Hierarchy (View Summary)

    Implements

    Index
    • Parameters

      • x: number

        The horizontal position of the light.

      • y: number

        The vertical position of the light.

      • radius: number

        The radius of the light.

      • r: number

        The red color of the light. A value between 0 and 1.

      • g: number

        The green color of the light. A value between 0 and 1.

      • b: number

        The blue color of the light. A value between 0 and 1.

      • intensity: number

        The intensity of the light.

      • Optionalz: number

        The z position of the light. If not given, it will be set to radius * 0.1.

      Returns Light

    bottom: number

    The bottommost point of the Circle, equal to y + radius. Setting this value adjusts the y position of the circle's center while keeping the radius unchanged.

    cameraFilter: number

    A bitmask that controls if this Game Object is drawn by a Camera or not. Not usually set directly, instead call Camera.ignore, however you can set this property directly using the Camera.id property:

    color: RGB

    The color of the light.

    coneEnabled: boolean

    Whether this Light is restricted to a cone.

    coneInnerAngle: number

    The inner cone angle, in radians. Fragments inside this angle receive full light.

    coneOuterAngle: number

    The outer cone angle, in radians. Fragments outside this angle receive no light.

    coneRotation: number

    The cone direction, in radians, in world space.

    diameter: number

    The diameter of the Circle, which is twice the radius. Setting this value also updates the radius accordingly.

    displayHeight: number

    The height of this Light Game Object. This is the same as Light.diameter.

    displayOriginX: number

    The horizontal display origin of this Game Object, expressed in pixels. Unlike originX, which is a normalized value between 0 and 1, the display origin is the calculated pixel offset derived from the Game Object's width multiplied by its originX value. Setting this property updates originX accordingly.

    displayOriginY: number

    The vertical display origin of this Game Object, expressed in pixels. Unlike originY, which is a normalized value between 0 and 1, the display origin is the calculated pixel offset derived from the Game Object's height multiplied by its originY value. Setting this property updates originY accordingly.

    displayWidth: number

    The width of this Light Game Object. This is the same as Light.diameter.

    height: number

    The height of this Light Game Object. This is the same as Light.diameter.

    intensity: number

    The intensity of the light. This scales the overall brightness of the light effect. A value of 1 is considered normal brightness. Higher values produce a stronger, brighter light.

    left: number

    The leftmost point of the Circle, equal to x - radius. Setting this value adjusts the x position of the circle's center while keeping the radius unchanged.

    originX: number

    The horizontal origin of this Game Object. The origin maps the relationship between the size and position of the Game Object. The default value is 0.5, meaning all Game Objects are positioned based on their center. Setting the value to 0 means the position now relates to the left of the Game Object. Set this value with setOrigin().

    originY: number

    The vertical origin of this Game Object. The origin maps the relationship between the size and position of the Game Object. The default value is 0.5, meaning all Game Objects are positioned based on their center. Setting the value to 0 means the position now relates to the top of the Game Object. Set this value with setOrigin().

    radius: number

    The radius of the Circle. Setting this value also updates the diameter accordingly.

    renderFlags: number

    The flags that are compared against RENDER_MASK to determine if this Light will render or not. The relevant bit is 0001, set by the Visible component. The remaining bits are unused by Light but are reserved for custom use if required.

    right: number

    The rightmost point of the Circle, equal to x + radius. Setting this value adjusts the x position of the circle's center while keeping the radius unchanged.

    scrollFactorX: number

    The horizontal scroll factor of this Game Object.

    The scroll factor controls the influence of the movement of a Camera upon this Game Object.

    When a camera scrolls it will change the location at which this Game Object is rendered on-screen. It does not change the Game Objects actual position values.

    A value of 1 means it will move exactly in sync with a camera. A value of 0 means it will not move at all, even if the camera moves. Other values control the degree to which the camera movement is mapped to this Game Object.

    Please be aware that scroll factor values other than 1 are not taken into consideration when calculating physics collisions. Bodies always collide based on their world position, but changing the scroll factor is a visual adjustment to where the textures are rendered, which can offset them from physics bodies if not accounted for in your code.

    scrollFactorY: number

    The vertical scroll factor of this Game Object.

    The scroll factor controls the influence of the movement of a Camera upon this Game Object.

    When a camera scrolls it will change the location at which this Game Object is rendered on-screen. It does not change the Game Objects actual position values.

    A value of 1 means it will move exactly in sync with a camera. A value of 0 means it will not move at all, even if the camera moves. Other values control the degree to which the camera movement is mapped to this Game Object.

    Please be aware that scroll factor values other than 1 are not taken into consideration when calculating physics collisions. Bodies always collide based on their world position, but changing the scroll factor is a visual adjustment to where the textures are rendered, which can offset them from physics bodies if not accounted for in your code.

    top: number

    The topmost point of the Circle, equal to y - radius. Setting this value adjusts the y position of the circle's center while keeping the radius unchanged.

    type: number

    The geometry constant type of this object: GEOM_CONST.CIRCLE. Used for fast type comparisons.

    visible: boolean

    The visible state of the Game Object.

    An invisible Game Object will skip rendering, but will still process update logic.

    width: number

    The width of this Light Game Object. This is the same as Light.diameter.

    x: number

    The x position of the center of the circle.

    y: number

    The y position of the center of the circle.

    z: number

    The z position of the light. This affects the relief effect created by the light. A higher value will make the light appear more raised.

    Lit game objects are considered to be at z=0. Thus, if z is larger than the radius of the light, the light will not affect them. Strong values are in the range of 0 to radius/2.

    This is not a true position, and won't be affected by perspective or camera position. It won't be set by setTo. Use setZ to set it, or setZNormal to set it to a fraction of the radius.

    zNormal: number

    The z position of the light, as a fraction of the radius. This affects the relief effect created by the light. A higher value will make the light appear more raised. Strong values are in the range of 0 to 0.5.

    RENDER_MASK: number

    The bitmask that GameObject.renderFlags is compared against to determine if the Game Object will render or not.

    • Check to see if the Circle contains the given x / y coordinates.

      Parameters

      • x: number

        The x coordinate to check within the circle.

      • y: number

        The y coordinate to check within the circle.

      Returns boolean

      True if the coordinates are within the circle, otherwise false.

    • Disable cone limiting and make this Light omnidirectional again.undefined

      Returns this

      This Light object.

    • Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point at 180 degrees around the circle.

      Type Parameters

      Parameters

      • position: number

        A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle.

      • Optionalout: O

        A Vector2 to store the return values in. If not given a Vector2 object will be created.

      Returns O

      A Vector2 containing the coordinates of the point around the circle.

    • Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, based on the given quantity or stepRate values.

      Type Parameters

      Parameters

      • quantity: number

        The amount of points to return. If a falsy value the quantity will be derived from the stepRate instead.

      • OptionalstepRate: number

        Sets the quantity by getting the circumference of the circle and dividing it by the stepRate.

      • Optionaloutput: O

        An array to insert the Vector2s in to. If not provided a new array will be created.

      Returns O

      An array of Vector2 objects pertaining to the points around the circumference of the circle.

    • Returns a uniformly distributed random point from anywhere within the Circle.

      Type Parameters

      Parameters

      • Optionalvec: Vector2

        A Vector2 object to set the random x and y values in.

      Returns O

      A Vector2 object with the random values set in the x and y properties.

    • Checks to see if the Circle is empty: has a radius of zero.undefined

      Returns boolean

      True if the Circle is empty, otherwise false.

    • Set the color of the light from a single integer RGB value.

      Parameters

      • rgb: number

        The integer RGB color of the light.

      Returns this

      This Light object.

    • Restrict this Light to a cone, suitable for flashlights, lanterns and other focal lights.

      The rotation is in radians, where 0 points to the right in world space. The innerAngle is the fully-lit cone width. The outerAngle is the wider falloff cone width; if omitted, the cone has a hard edge. Both angles are full cone widths, not half-angles.

      Parameters

      • rotation: number

        The direction of the cone, in radians.

      • innerAngle: number

        The fully-lit cone width, in radians.

      • OptionalouterAngle: number

        The outer falloff cone width, in radians. Default innerAngle.

      Returns this

      This Light object.

    • Set the inner and outer cone angles, in radians.

      Parameters

      • innerAngle: number

        The fully-lit cone width, in radians.

      • OptionalouterAngle: number

        The outer falloff cone width, in radians. Default innerAngle.

      Returns this

      This Light object.

    • Set the direction of this Light cone, in radians.

      Parameters

      • rotation: number

        The direction of the cone, in radians.

      Returns this

      This Light object.

    • Sets the display origin of this Game Object. The difference between this and setting the origin is that you can use pixel values for setting the display origin.

      Parameters

      • Optionalx: number

        The horizontal display origin value. Default 0.

      • Optionaly: number

        The vertical display origin value. If not defined it will be set to the value of x. Default x.

      Returns this

      This Game Object instance.

    • Sets this Circle to be empty with a radius of zero. Does not change its position.undefined

      Returns this

      This Circle object.

    • Set the intensity of the light. This scales the overall brightness of the light effect. A value of 1 is considered normal brightness. Higher values produce a stronger, brighter light.

      Parameters

      • intensity: number

        The intensity (brightness multiplier) of the light.

      Returns this

      This Light object.

    • Sets the origin of this Game Object.

      The values are given in the range 0 to 1.

      Parameters

      • Optionalx: number

        The horizontal origin value. Default 0.5.

      • Optionaly: number

        The vertical origin value. If not defined it will be set to the value of x. Default x.

      Returns this

      This Game Object instance.

    • Sets the origin of this Game Object based on the Pivot values in its Frame. If the Frame has a custom pivot point defined, the origin is set to match it. If the Frame does not have a custom pivot, this method falls back to setOrigin(), resetting the origin to the default value of 0.5 for both axes.undefined

      Returns this

      This Game Object instance.

    • Sets the position of this Circle. If the y argument is omitted, both the x and y positions will be set to the value of x.

      Parameters

      • Optionalx: number

        The x position of the center of the circle. Default 0.

      • Optionaly: number

        The y position of the center of the circle. Default 0.

      Returns this

      This Circle object.

    • Set the radius of the light, in pixels. This defines the circular area of influence within which lit Game Objects will be affected by this light.

      Parameters

      • radius: number

        The radius of the light, in pixels.

      Returns this

      This Light object.

    • Sets the horizontal and vertical scroll factor of this Game Object. If only the x value is provided, it is applied to both axes. This is a convenience method for setting scrollFactorX and scrollFactorY in a single call.

      The scroll factor controls the influence of the movement of a Camera upon this Game Object.

      When a camera scrolls it will change the location at which this Game Object is rendered on-screen. It does not change the Game Objects actual position values.

      A value of 1 means it will move exactly in sync with a camera. A value of 0 means it will not move at all, even if the camera moves. Other values control the degree to which the camera movement is mapped to this Game Object.

      Please be aware that scroll factor values other than 1 are not taken into consideration when calculating physics collisions. Bodies always collide based on their world position, but changing the scroll factor is a visual adjustment to where the textures are rendered, which can offset them from physics bodies if not accounted for in your code.

      Parameters

      • x: number

        The horizontal scroll factor of this Game Object.

      • Optionaly: number

        The vertical scroll factor of this Game Object. If not set it will use the x value. Default x.

      Returns this

      This Game Object instance.

    • Sets the x, y and radius of this circle.

      Parameters

      • Optionalx: number

        The x position of the center of the circle. Default 0.

      • Optionaly: number

        The y position of the center of the circle. Default 0.

      • Optionalradius: number

        The radius of the circle. Default 0.

      Returns this

      This Circle object.

    • Sets the visibility of this Game Object.

      An invisible Game Object will skip rendering, but will still process update logic.

      Parameters

      • value: boolean

        The visible state of the Game Object.

      Returns this

      This Game Object instance.

    • Set the z position of the light. This controls the perceived height of the light above the scene, which influences the relief (normal-map shading) effect. Larger values make the light appear more elevated. Lit Game Objects are considered to be at z=0, so if z exceeds the light's radius the light will not affect them. Strong values are in the range of 0 to radius/2.

      Parameters

      • z: number

        The z position of the light, where 0 is at the same level as lit Game Objects.

      Returns this

      This Light object.

    • Set the z position of the light as a fraction of the radius. This affects the relief effect created by the light. A higher value will make the light appear more raised. Strong values are in the range of 0 to 0.5.

      Parameters

      • z: number

        The normalized z position of the light.

      Returns this

      This Light object.

    • Updates the Display Origin cached values internally stored on this Game Object. You don't usually call this directly, but it is exposed for edge-cases where you may.undefined

      Returns this

      This Game Object instance.

    • Compares the renderMask with the renderFlags to see if this Game Object will render or not. Also checks the Game Object against the given Cameras exclusion list.

      Parameters

      • camera: Camera

        The Camera to check against this Game Object.

      Returns boolean

      True if the Game Object should be rendered, otherwise false.

    • Calculates the area of the circle.

      Parameters

      • circle: Circle

        The Circle to get the area of.

      Returns number

      The area of the Circle.

    • Returns the circumference of the given Circle.

      Parameters

      • circle: Circle

        The Circle to get the circumference of.

      Returns number

      The circumference of the Circle.

    • Returns a Vector2 object containing the coordinates of a point on the circumference of the Circle based on the given angle.

      Type Parameters

      Parameters

      • circle: Circle

        The Circle to get the circumference point on.

      • angle: number

        The angle from the center of the Circle to the circumference to return the point from. Given in radians.

      • Optionalout: O

        A Vector2 to store the results in. If not given a Vector2 will be created.

      Returns O

      A Vector2 object where the x and y properties are the point on the circumference.

    • Creates a new Circle instance based on the values contained in the given source.

      Parameters

      • source: object | Circle

        The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties.

      Returns Circle

      A clone of the source Circle.

    • Check to see if the Circle contains the given x / y coordinates.

      Parameters

      • circle: Circle

        The Circle to check.

      • x: number

        The x coordinate to check within the circle.

      • y: number

        The y coordinate to check within the circle.

      Returns boolean

      True if the coordinates are within the circle, otherwise false.

    • Check to see if the Circle contains the given x and y coordinates as stored in the Vector2.

      Parameters

      • circle: Circle

        The Circle to check.

      • vec: Vector2

        The Vector2 object to check if its coordinates are within the Circle or not.

      Returns boolean

      True if the Vector2 coordinates are within the circle, otherwise false.

    • Check to see if the Circle contains all four points of the given Rectangle object.

      Parameters

      • circle: Circle

        The Circle to check.

      • rect: object | Rectangle

        The Rectangle object to check if it's within the Circle or not.

      Returns boolean

      True if all of the Rectangle coordinates are within the circle, otherwise false.

    • Copies the x, y and radius properties from the source Circle into the given dest Circle, then returns the dest Circle.

      Type Parameters

      Parameters

      • source: Circle

        The source Circle to copy the values from.

      • dest: O

        The destination Circle to copy the values to.

      Returns O

      The destination Circle.

    • Compares the x, y and radius properties of the two given Circles. Returns true if they all match, otherwise returns false.

      Parameters

      • circle: Circle

        The first Circle to compare.

      • toCompare: Circle

        The second Circle to compare.

      Returns boolean

      true if the two Circles equal each other, otherwise false.

    • Returns the bounds of the Circle object.

      Type Parameters

      Parameters

      • circle: Circle

        The Circle to get the bounds from.

      • Optionalout: O

        A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created.

      Returns O

      The Rectangle object containing the Circle's bounds.

    • Returns a Vector2 object containing the coordinates of a point on the circumference of the Circle based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point at 180 degrees around the circle.

      Type Parameters

      Parameters

      • circle: Circle

        The Circle to get the circumference point on.

      • position: number

        A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle.

      • Optionalout: O

        A Vector2 instance to store the return values in. If not given a new Vector2 object will be created.

      Returns O

      A Vector2 containing the coordinates of the point around the circle.

    • Returns an array of Vector2 objects containing the coordinates of the points around the circumference of the Circle, based on the given quantity or stepRate values.

      Parameters

      • circle: Circle

        The Circle to get the points from.

      • quantity: number

        The amount of points to return. If a falsy value the quantity will be derived from the stepRate instead.

      • OptionalstepRate: number

        Sets the quantity by getting the circumference of the circle and dividing it by the stepRate.

      • Optionalout: any[]

        An array to insert the points in to. If not provided a new array will be created.

      Returns Vector2[]

      An array of Vector2 objects pertaining to the points around the circumference of the circle.

    • Offsets the Circle by the values given.

      Type Parameters

      Parameters

      • circle: O

        The Circle to be offset (translated.)

      • x: number

        The amount to horizontally offset the Circle by.

      • y: number

        The amount to vertically offset the Circle by.

      Returns O

      The Circle that was offset.

    • Offsets the Circle by the values given in the x and y properties of the Vector2 object.

      Type Parameters

      Parameters

      • circle: O

        The Circle to be offset (translated.)

      • vec: Vector2

        The Vector2 object containing the values to offset the Circle by.

      Returns O

      The Circle that was offset.

    • Returns a uniformly distributed random point from anywhere within the given Circle.

      Type Parameters

      Parameters

      • circle: Circle

        The Circle to get a random point from.

      • Optionalout: O

        A Vector2 object to set the random x and y values in.

      Returns O

      A Vector2 object with the random values set in the x and y properties.