Property definitions

gamnit $ RoundControl :: defaultinit
# 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