VirtualControlsOpacity controls[,alpha#]

Parameters

controls: group handle. alpha: 0..1, clamped; default 0.65.

Description

Sets group opacity. Zero also releases input and disables hit testing so invisible buttons cannot trap input. Non-finite values are rejected. The separate Controls menu remains accessible.

Native overlays are supported on iOS, Android, macOS and Windows, including IDE run presets and saved layouts, and on the web, where the page draws them over the canvas. Controls use presentation coordinates, remain responsive during blocking input waits, and are excluded from SaveBuffer. See the mobile input guide.

Example

; VirtualControlsOpacity Example
; Virtual keyboard: movement and action use only existing keyboard commands.
Graphics 800,480,0,2
SetBuffer BackBuffer()
Local keys=CreateVirtualKeyboard("wasd")
If keys=0 Then RuntimeError MobileInputError$()
VirtualControlsOpacity keys,0.85
Local x#=400,y#=210,score=0,target_x#=530,target_y#=200
Local previous=MilliSecs()
While Not KeyHit(1)
    Local now=MilliSecs(),dt#=Float(now-previous)/1000
    previous=now
    If dt<0 Then dt=0
    If dt>0.05 Then dt=0.05
    x=x+(KeyDown(32)-KeyDown(30))*180*dt
    y=y+(KeyDown(31)-KeyDown(17))*180*dt
    If x<15 Then x=15
    If x>785 Then x=785
    If y<85 Then y=85
    If y>465 Then y=465
    If KeyHit(57)
        If (x-target_x)^2+(y-target_y)^2<65^2
            score=score+1
            target_x=Rnd(180,610)
            target_y=Rnd(120,280)
        EndIf
    EndIf
    If KeyHit(28) Then score=0
    Cls
    Color 255,255,255
    Text 20,48,"Move with WASD; press Space near the gold target. Score: "+score
    Text 20,68,"Enter resets. Esc exits. Controls opens layout options; drag its tab to move it."
    Color 255,200,40
    Oval target_x-15,target_y-15,30,30,True
    Color 70,200,255
    If KeyDown(57) Then Color 255,255,255
    Oval x-12,y-12,24,24,True
    Flip
Wend
FreeVirtualControls keys
End

Open example ยท Command index