Class Parallax2D
- Namespace
- Godot
- Assembly
- GodotSharp.dll
A Parallax2D is used to create a parallax effect. It can move at a different speed relative to the camera movement using ScrollScale. This creates an illusion of depth in a 2D game. If manual scrolling is desired, the Camera2D position can be ignored with IgnoreCameraScroll.
Note: Any changes to this node's position made after it enters the scene tree will be overridden if IgnoreCameraScroll is false or ScreenOffset is modified.
public class Parallax2D : Node2D, IDisposable
- Inheritance
-
Parallax2D
- Implements
- Inherited Members
Constructors
Parallax2D()
public Parallax2D()
Properties
Autoscroll
Velocity at which the offset scrolls automatically, in pixels per second.
public Vector2 Autoscroll { get; set; }
Property Value
FollowViewport
If true, this Parallax2D is offset by the current camera's position. If the Parallax2D is in a CanvasLayer separate from the current camera, it may be desired to match the value with FollowViewportEnabled.
public bool FollowViewport { get; set; }
Property Value
IgnoreCameraScroll
If true, Parallax2D's position is not affected by the position of the camera.
public bool IgnoreCameraScroll { get; set; }
Property Value
LimitBegin
Top-left limits for scrolling to begin. If the camera is outside of this limit, the Parallax2D stops scrolling. Must be lower than LimitEnd minus the viewport size to work.
public Vector2 LimitBegin { get; set; }
Property Value
LimitEnd
Bottom-right limits for scrolling to end. If the camera is outside of this limit, the Parallax2D will stop scrolling. Must be higher than LimitBegin and the viewport size combined to work.
public Vector2 LimitEnd { get; set; }
Property Value
RepeatSize
Repeats the Texture2D of each of this node's children and offsets them by this value. When scrolling, the node's position loops, giving the illusion of an infinite scrolling background if the values are larger than the screen size. If an axis is set to 0
, the Texture2D will not be repeated.
public Vector2 RepeatSize { get; set; }
Property Value
RepeatTimes
Overrides the amount of times the texture repeats. Each texture copy spreads evenly from the original by RepeatSize. Useful for when zooming out with a camera.
public int RepeatTimes { get; set; }
Property Value
ScreenOffset
Offset used to scroll this Parallax2D. This value is updated automatically unless IgnoreCameraScroll is true.
public Vector2 ScreenOffset { get; set; }
Property Value
ScrollOffset
The Parallax2D's offset. Similar to ScreenOffset and Position, but will not be overridden.
Note: Values will loop if RepeatSize is set higher than 0
.
public Vector2 ScrollOffset { get; set; }
Property Value
ScrollScale
Multiplier to the final Parallax2D's offset. Can be used to simulate distance from the camera.
For example, a value of 1
scrolls at the same speed as the camera. A value greater than 1
scrolls faster, making objects appear closer. Less than 1
scrolls slower, making objects appear further, and a value of 0
stops the objects completely.
public Vector2 ScrollScale { get; set; }
Property Value
Methods
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.