button
A tap-to-press button with haptic feedback. Emits press when the player puts their finger down and release when they lift it. The cleanest input for any “do X now” action.
C# factory
WidgetDefinitions.Button( id: "btn_a", label: "Jump", positionX: 0.85f, positionY: 0.8f, sizeW: 0.18f, sizeH: 0.12f, color: "#3b82f6", haptic: true);Wire format
| Field | Type | Required | Notes |
|---|---|---|---|
id | string | yes | |
type | "button" | yes | |
position_x, position_y | number | no | 0..1 anchor. |
size_w, size_h | number | no | 0..1 fraction of the screen. |
label | string | no | Button text. Supports {key} bindings against screen.data. |
color | string | no | 7-digit hex (e.g. #3b82f6) for the fill. |
haptic | boolean | no | Vibrate on press. Default true. |
disabled_key | string | no | Disable when screen.data[key] is truthy. |
Events
| Event type | Payload | Fires when |
|---|---|---|
press | {} | Pointer down on the button. |
release | {} | Pointer up or pointer leaves the button. |
Example
manager.OnInput += (player, evt) =>{ if (evt.WidgetId == "btn_a" && evt.EventType == "press") { player.Avatar.Jump(); manager.SendToPlayer(player.Id, "vibrate", new { duration_ms = 60 }); }};