I'm having an issue with re-activating a virtual button. See the following code for a simple example. An example of usage in a game would be, one button for "Return to Game" and one for "Help". The "Return to Game" button would start inactive & invisible, then clicking "Help" would display the Help screen and activate & display the "Return to Game" button. Clicking the "Return to Game" button would hide the Help screen and deactivate & hide the "Return to Game" button.
The problem I'm seeing is that this logic works once, but the next time you click on "Help", the Help screen (w/ Return to Game button) flashes quickly then goes away.
Debug output shows me that the program registers a "phantom" click of the Return to Game button immediately after clicking the Help button.
I've tried adding Sleep statements to change the timing, with same results.
I also tried setting a game state that would skip one game loop after clicking Help. This helped a little, the problem still occurred, but slightly less often.
The issue does not occur if the re-activation is removed, so it appears to be caused by the second activation.
Sample code exhibiting issue:
// Project: ButtonTest
// Created: 2016-05-14
// set window properties
SetWindowTitle( "ButtonTest" )
SetWindowSize( 360, 640, 0 )
// set display properties
SetDisplayAspect(360.0/640)
SetOrientationAllowed( 1, 1, 1, 1 )
// first button
AddVirtualButton(1,95,25,10)
SetVirtualButtonText(1,"One")
//second button
AddVirtualButton(2,95,35,10)
SetVirtualButtonText(2,"Two")
SetVirtualButtonVisible(2,0) //invisible
SetVirtualButtonActive(2,0) //inactive
do
if GetVirtualButtonPressed(1)
SetVirtualButtonVisible(2,1) //button 2 visible
SetVirtualButtonActive(2,1) //button 2 active
endif
if GetVirtualButtonPressed(2)
SetVirtualButtonVisible(2,0) //button 2 invisible
SetVirtualButtonActive(2,0) //button 2 inactive
endif
Sync()
loop