Skip to content

KernelAPI reference

Class HeadlessTouchScreen

Namespace: MicroEngine.Core
Assembly: MicroEngine.dll
Guide: Game lifecycle and time

A touch screen for tests: fingers go down, move and lift by hand, the size, safe area and density can change (a rotation, a notch), vibrations are counted, and DrawOverlay records what the overlay draws.

C#
public sealed class HeadlessTouchScreen : ITouchScreen

Inheritance

object ← HeadlessTouchScreen

Implements

ITouchScreen

Constructors

HeadlessTouchScreen(Vector2)

A touch screen for tests: fingers go down, move and lift by hand, the size, safe area and density can change (a rotation, a notch), vibrations are counted, and DrawOverlay records what the overlay draws.

C#
public HeadlessTouchScreen(Vector2 size)

Parameters

size Vector2

Properties

CanVibrate

Whether Vibrate can do anything here.

C#
public bool CanVibrate { get; set; }

Property Value

bool

Overlay

Drawn over the letterboxed game in screen pixels after every frame (never in captures).

C#
public ITouchOverlay? Overlay { get; set; }

Property Value

ITouchOverlay?

PixelsPerDp

Pixels per density-independent pixel (1/160 inch): 1 on a classic desktop display, 2-4 on phones.

C#
public float PixelsPerDp { get; set; }

Property Value

float

SafeArea

Defaults to the whole screen.

C#
public RectF SafeArea { get; set; }

Property Value

RectF

Size

Drawable size in pixels.

C#
public Vector2 Size { get; set; }

Property Value

Vector2

TouchFirst

Whether touch is the main way to play here (a phone, a tablet, a touch-only browser).

C#
public bool TouchFirst { get; set; }

Property Value

bool

Vibrations

Successful Vibrate calls so far.

C#
public int Vibrations { get; }

Property Value

int

Methods

Cancel(long)

Cancels finger, as the system does when the game loses the screen.

C#
public void Cancel(long finger)

Parameters

finger long

Down(long, float, float)

Puts finger down at (x, y) in screen pixels; delivered at the next read.

C#
public void Down(long finger, float x, float y)

Parameters

finger long

x float

y float

Down(long, Vector2)

Puts finger down at at in screen pixels.

C#
public void Down(long finger, Vector2 at)

Parameters

finger long

at Vector2

DrawOverlay()

Draws the overlay into a recorder and returns what it drew.

C#
public RecordingOverlayCanvas DrawOverlay()

Returns

RecordingOverlayCanvas

Move(long, Vector2)

Moves finger to at.

C#
public void Move(long finger, Vector2 at)

Parameters

finger long

at Vector2

ReadTouches(List<TouchEvent>)

Moves every touch event since the previous call into events, oldest first.

C#
public void ReadTouches(List<TouchEvent> events)

Parameters

events List<TouchEvent>

Up(long, Vector2)

Lifts finger.

C#
public void Up(long finger, Vector2 at = default)

Parameters

finger long

at Vector2

Vibrate(float, int)

Counts the vibration in Vibrations; false when CanVibrate is false.

C#
public bool Vibrate(float strength, int milliseconds)

Parameters

strength float

milliseconds int

Returns

bool