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).
public sealed class GameViewsInheritance
Properties
CanvasSize
The canvas’s size in pixels (the world view’s resolution).
public Vector2 CanvasSize { get; }Property Value
HasScreenView
Whether the platform draws the UI view at the window’s resolution (false: the UI view is the canvas).
public bool HasScreenView { get; }Property Value
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.
public bool PointerOnUi { get; }Property Value
ScreenSize
The window’s size in pixels; the canvas’s size where the platform has no UI view.
public Vector2 ScreenSize { get; }Property Value
UiPointer
The pointer in UI units.
public PointerState UiPointer { get; }Property Value
UiScale
Window pixels per UI unit.
public float UiScale { get; }Property Value
UiSize
The UI view’s size in UI units.
public Vector2 UiSize { get; }Property Value
WorldFrame
Where the canvas lands in the window, in window pixels.
public RectF WorldFrame { get; }Property Value
Methods
CanvasToScreen(Vector2)
A canvas position in window pixels.
public Vector2 CanvasToScreen(Vector2 canvas)Parameters
canvas Vector2
Returns
CanvasToUi(Vector2)
A canvas position in UI units (to place a label over a world object).
public Vector2 CanvasToUi(Vector2 canvas)Parameters
canvas Vector2
Returns
ScreenToCanvas(Vector2)
A window position (pixels) in canvas pixels.
public Vector2 ScreenToCanvas(Vector2 screen)Parameters
screen Vector2
Returns
ScreenToUi(Vector2)
A window position (pixels) in UI units.
public Vector2 ScreenToUi(Vector2 screen)Parameters
screen Vector2
Returns
UiToCanvas(Vector2)
A UI position in canvas pixels.
public Vector2 UiToCanvas(Vector2 ui)Parameters
ui Vector2
Returns
UiToScreen(Vector2)
A UI position in window pixels.
public Vector2 UiToScreen(Vector2 ui)Parameters
ui Vector2
Returns
WorldPointer(Camera2D?)
The pointer in the world of camera (canvas pixels without one); not present while it is over the
UI (PointerOnUi).
public PointerState WorldPointer(Camera2D? camera = null)Parameters
camera Camera2D?