Skip to content

GraphicsAPI reference

Class ParallaxLayer

Namespace: MicroEngine.Graphics
Assembly: MicroEngine.Graphics2D.dll
Guide: Graphics

A background image that scrolls slower (or faster) than the camera and repeats horizontally. Draw it in screen space (no camera pushed). Factor 0 is fixed to the screen, 1 moves with the world. Y is the screen row of the image’s top edge; the optional VerticalFactor lets tall worlds shift it as the camera rises or falls.

C#
public sealed class ParallaxLayer

Inheritance

object ← ParallaxLayer

Constructors

ParallaxLayer(Texture)

A background image that scrolls slower (or faster) than the camera and repeats horizontally. Draw it in screen space (no camera pushed). Factor 0 is fixed to the screen, 1 moves with the world. Y is the screen row of the image’s top edge; the optional VerticalFactor lets tall worlds shift it as the camera rises or falls.

C#
public ParallaxLayer(Texture texture)

Parameters

texture Texture

Properties

Drift

Extra horizontal offset in screen pixels per second (drifting clouds, traffic).

C#
public float Drift { get; init; }

Property Value

float

Factor

Horizontal scroll relative to the camera: 0 stays fixed, 1 moves with the world (0.5 by default).

C#
public float Factor { get; init; }

Property Value

float

RepeatX

Whether the image repeats to cover the screen width (true by default).

C#
public bool RepeatX { get; init; }

Property Value

bool

Texture

The image; the layer does not dispose it.

C#
public Texture Texture { get; }

Property Value

Texture

Tint

Colour multiplier (white by default).

C#
public Color Tint { get; init; }

Property Value

Color

VerticalFactor

Vertical scroll relative to the camera (0 by default: the layer stays at Y).

C#
public float VerticalFactor { get; init; }

Property Value

float

Y

Screen row of the image’s top edge when the camera is at Y = 0.

C#
public float Y { get; init; }

Property Value

float

Methods

Draw(IRenderer, Vector2, float)

Draws the layer in screen space.

C#
public void Draw(IRenderer r, Vector2 cameraPosition, float time = 0)

Parameters

r IRenderer

The renderer, with no camera pushed.

cameraPosition Vector2

The camera’s Position.

time float

Seconds used by Drift, for example the game’s Time.