Skip to content

InputAPI reference

Class TouchLayout

Namespace: MicroEngine.Input
Assembly: MicroEngine.Input.Touch.dll
Guide: Input

A game’s on-screen controls: which controls, where, and how they look and feel. The same layout is used on phones (SDL), in mobile browsers and in tests; games return theirs from Game.CreateTouchLayout.

C#
public sealed record TouchLayout : IEquatable<TouchLayout>

Inheritance

object ← TouchLayout

Implements

IEquatable<TouchLayout>

Constructors

TouchLayout()

C#
public TouchLayout()

Properties

ButtonStyle

How buttons look (null: the default style).

C#
public TouchStyle? ButtonStyle { get; init; }

Property Value

TouchStyle?

Controls

The controls, drawn in order; ids must be unique.

C#
public IReadOnlyList<TouchControl> Controls { get; init; }

Property Value

IReadOnlyList<TouchControl>

DPadStyle

How d-pads look (null: the default style).

C#
public TouchStyle? DPadStyle { get; init; }

Property Value

TouchStyle?

Haptics

A short vibration on each press where the device can vibrate.

C#
public bool Haptics { get; init; }

Property Value

bool

HitScale

The touchable area as a multiple of the drawn radius (overlaps go to the nearest control).

C#
public float HitScale { get; init; }

Property Value

float

Opacity

Opacity of idle controls, 0..1. Pressed controls are always more opaque.

C#
public float Opacity { get; init; }

Property Value

float

PressedTint

Fill of a pressed control.

C#
public Color PressedTint { get; init; }

Property Value

Color

Scale

Size factor on top of the screen’s density (a player setting).

C#
public float Scale { get; init; }

Property Value

float

Skin

Draws the controls (null: DefaultTouchSkin, shaped by the styles). Replace it for a look styles cannot give.

C#
public ITouchSkin? Skin { get; init; }

Property Value

ITouchSkin?

SlideBetweenButtons

Whether a finger that slides onto another button presses it instead (fire-and-jump rolls); toggle buttons are never slid onto.

C#
public bool SlideBetweenButtons { get; init; }

Property Value

bool

SlideTolerance

A held button stays pressed until its finger is this many touchable radii from its centre.

C#
public float SlideTolerance { get; init; }

Property Value

float

StickStyle

How joysticks look (null: the default style).

C#
public TouchStyle? StickStyle { get; init; }

Property Value

TouchStyle?

Tint

Colour of outlines and labels.

C#
public Color Tint { get; init; }

Property Value

Color

Visibility

When the controls are drawn (automatic by default).

C#
public TouchVisibility Visibility { get; init; }

Property Value

TouchVisibility

Methods

<Clone>$()

C#
public TouchLayout <Clone>$()

Returns

TouchLayout

CreateDefault(ActionNames?)

The layout for CreateDefault: a d-pad on the left; confirm (A), cancel (B) and action (C) on the right; pause at the top right. names are the actions they press (null: the default names); the controls keep the default names as their ids.

C#
public static TouchLayout CreateDefault(ActionNames? names = null)

Parameters

names ActionNames?

Returns

TouchLayout

Equals(object?)

C#
public override bool Equals(object? obj)

Parameters

obj object?

Returns

bool

Equals(TouchLayout?)

C#
public bool Equals(TouchLayout? other)

Parameters

other TouchLayout?

Returns

bool

GetHashCode()

C#
public override int GetHashCode()

Returns

int

Of(params TouchControl[])

A layout with these controls and the default look.

C#
public static TouchLayout Of(params TouchControl[] controls)

Parameters

controls TouchControl[]

Returns

TouchLayout

StyleOf(TouchControl)

The style control is drawn with: its own, else its kind’s, else the default.

C#
public TouchStyle StyleOf(TouchControl control)

Parameters

control TouchControl

Returns

TouchStyle

ToString()

C#
public override string ToString()

Returns

string

Operators

operator ==(TouchLayout?, TouchLayout?)

C#
public static bool operator ==(TouchLayout? left, TouchLayout? right)

Parameters

left TouchLayout?

right TouchLayout?

Returns

bool

operator !=(TouchLayout?, TouchLayout?)

C#
public static bool operator !=(TouchLayout? left, TouchLayout? right)

Parameters

left TouchLayout?

right TouchLayout?

Returns

bool