Parallax2D

package
v0.0.0-...-357ca8a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsParallax2D() Instance
}

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsCanvasItem

func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsNode2D

func (self *Extension[T]) AsNode2D() Node2D.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsParallax2D

func (self *Extension[T]) AsParallax2D() Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.Parallax2D

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsCanvasItem

func (self Instance) AsCanvasItem() CanvasItem.Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsNode2D

func (self Instance) AsNode2D() Node2D.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsParallax2D

func (self Instance) AsParallax2D() Instance

func (Instance) Autoscroll

func (self Instance) Autoscroll() Vector2.XY

Velocity at which the offset scrolls automatically, in pixels per second.

func (Instance) FollowViewport

func (self Instance) FollowViewport() bool

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 CanvasLayer.FollowViewportEnabled.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) IgnoreCameraScroll

func (self Instance) IgnoreCameraScroll() bool

If true, Parallax2D's position is not affected by the position of the camera.

func (Instance) LimitBegin

func (self Instance) LimitBegin() Vector2.XY

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.

func (Instance) LimitEnd

func (self Instance) LimitEnd() Vector2.XY

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.

func (Instance) RepeatSize

func (self Instance) RepeatSize() Vector2.XY

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.

func (Instance) RepeatTimes

func (self Instance) RepeatTimes() int

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.

func (Instance) ScreenOffset

func (self Instance) ScreenOffset() Vector2.XY

Offset used to scroll this Parallax2D. This value is updated automatically unless IgnoreCameraScroll is true.

func (Instance) ScrollOffset

func (self Instance) ScrollOffset() Vector2.XY

The Parallax2D's offset. Similar to ScreenOffset and Node2D.Position, but will not be overridden.

Note: Values will loop if RepeatSize is set higher than 0.

func (Instance) ScrollScale

func (self Instance) ScrollScale() Vector2.XY

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.

func (Instance) SetAutoscroll

func (self Instance) SetAutoscroll(value Vector2.XY)

SetAutoscroll sets the property returned by [GetAutoscroll].

func (Instance) SetFollowViewport

func (self Instance) SetFollowViewport(value bool)

SetFollowViewport sets the property returned by [GetFollowViewport].

func (Instance) SetIgnoreCameraScroll

func (self Instance) SetIgnoreCameraScroll(value bool)

SetIgnoreCameraScroll sets the property returned by [IsIgnoreCameraScroll].

func (Instance) SetLimitBegin

func (self Instance) SetLimitBegin(value Vector2.XY)

SetLimitBegin sets the property returned by [GetLimitBegin].

func (Instance) SetLimitEnd

func (self Instance) SetLimitEnd(value Vector2.XY)

SetLimitEnd sets the property returned by [GetLimitEnd].

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetRepeatSize

func (self Instance) SetRepeatSize(value Vector2.XY)

SetRepeatSize sets the property returned by [GetRepeatSize].

func (Instance) SetRepeatTimes

func (self Instance) SetRepeatTimes(value int)

SetRepeatTimes sets the property returned by [GetRepeatTimes].

func (Instance) SetScreenOffset

func (self Instance) SetScreenOffset(value Vector2.XY)

SetScreenOffset sets the property returned by [GetScreenOffset].

func (Instance) SetScrollOffset

func (self Instance) SetScrollOffset(value Vector2.XY)

SetScrollOffset sets the property returned by [GetScrollOffset].

func (Instance) SetScrollScale

func (self Instance) SetScrollScale(value Vector2.XY)

SetScrollScale sets the property returned by [GetScrollScale].

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL