Skip to content

KernelAPI reference

Class GameViews

Namespace: MicroEngine.Core
Assembly: MicroEngine.dll
Guide: The world view and the UI view

The game’s two views and the mapping between them (Views): the world view (the canvas, at the canvas’s resolution, placed in the window by the presentation) and the UI view (the window’s resolution, in UI units), drawn over it. Positions convert between window pixels, canvas pixels and UI units, and the pointer is given in each view; the UI view gets it first (PointerOnUi).

C#
public sealed class GameViews

Inheritance

object ← GameViews

Properties

CanvasSize

The canvas’s size in pixels (the world view’s resolution).

C#
public Vector2 CanvasSize { get; }

Property Value

Vector2

HasScreenView

Whether the platform draws the UI view at the window’s resolution (false: the UI view is the canvas).

C#
public bool HasScreenView { get; }

Property Value

bool

PointerOnUi

Whether the pointer is over the UI of a visible scene (UiContains): the UI view gets the pointer first, and WorldPointer is then not present.

C#
public bool PointerOnUi { get; }

Property Value

bool

ScreenSize

The window’s size in pixels; the canvas’s size where the platform has no UI view.

C#
public Vector2 ScreenSize { get; }

Property Value

Vector2

UiPointer

The pointer in UI units.

C#
public PointerState UiPointer { get; }

Property Value

PointerState

UiScale

Window pixels per UI unit.

C#
public float UiScale { get; }

Property Value

float

UiSize

The UI view’s size in UI units.

C#
public Vector2 UiSize { get; }

Property Value

Vector2

WorldFrame

Where the canvas lands in the window, in window pixels.

C#
public RectF WorldFrame { get; }

Property Value

RectF

Methods

CanvasToScreen(Vector2)

A canvas position in window pixels.

C#
public Vector2 CanvasToScreen(Vector2 canvas)

Parameters

canvas Vector2

Returns

Vector2

CanvasToUi(Vector2)

A canvas position in UI units (to place a label over a world object).

C#
public Vector2 CanvasToUi(Vector2 canvas)

Parameters

canvas Vector2

Returns

Vector2

ScreenToCanvas(Vector2)

A window position (pixels) in canvas pixels.

C#
public Vector2 ScreenToCanvas(Vector2 screen)

Parameters

screen Vector2

Returns

Vector2

ScreenToUi(Vector2)

A window position (pixels) in UI units.

C#
public Vector2 ScreenToUi(Vector2 screen)

Parameters

screen Vector2

Returns

Vector2

UiToCanvas(Vector2)

A UI position in canvas pixels.

C#
public Vector2 UiToCanvas(Vector2 ui)

Parameters

ui Vector2

Returns

Vector2

UiToScreen(Vector2)

A UI position in window pixels.

C#
public Vector2 UiToScreen(Vector2 ui)

Parameters

ui Vector2

Returns

Vector2

WorldPointer(Camera2D?)

The pointer in the world of camera (canvas pixels without one); not present while it is over the UI (PointerOnUi).

C#
public PointerState WorldPointer(Camera2D? camera = null)

Parameters

camera Camera2D?

Returns

PointerState