VirtualGamepad
gamnit :: RoundControl :: defaultinit
gamnit :: RoundControl :: radius
Radius in UI units/pixels of the part of this controlgamnit $ RoundControl :: SELF
Type of this instance, automatically specialized in every classcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
gamnit :: RoundControl :: defaultinit
core :: Object :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).gamnit :: RoundControl :: radius
Radius in UI units/pixels of the part of this control
# Control composing a `VirtualGamepad`
abstract class RoundControl
# Center position on the UI
var center: Point3d[Float]
# Radius in UI units/pixels of the part of this control
fun radius: Float is abstract
private fun sprites: Array[Sprite] do return new Array[Sprite]
private fun accept_event(event: InputEvent, ui_pos: Point[Float]): Bool
do
if event isa PointerEvent and contains(ui_pos) then
return hit(event, ui_pos)
end
return false
end
# Does `self` contain a pointer at `ui_pos`?
private fun contains(ui_pos: Point[Float]): Bool
do
var dx = center.x - ui_pos.x
var dy = center.y - ui_pos.y
return dx*dx + dy*dy < radius*radius
end
private fun hit(event: PointerEvent, ui_pos: Point[Float]): Bool
do return false
# Keys currently down, to be depressed if the pointer moves away
private var down_names = new Set[String]
# Depress/release keys kept down, listed by `down_names`
private fun depressed_down
do
for name in down_names do
var e = new VirtualGamepadEvent(name)
e.is_down = false
app.accept_event e
end
down_names.clear
end
end
lib/gamnit/virtual_gamepad/virtual_gamepad.nit:240,1--283,3