Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
rockethippo
4
Years of Service
User Offline
Joined: 25th Nov 2014
Location: Canada
Posted: 13th Feb 2015 07:26
I'm having trouble with a simple problem. When button 1 is pressed then released, I want the app to hide both buttons 1 and 2 then show a third button. When the third button is pressed, it will create a timer that corresponds with now long the third button has been held down. This is my current code

width = GetDeviceWidth ( )
height = GetDeviceHeight ( )
SetWindowTitle( "Don't let go!" )
SetScreenResolution( width, height )
SetOrientationAllowed( 1, 0, 0, 0 )
loadimage(1,"Sbutton.jpg")
loadimage(2,"Tbutton.jpg")
loadimage(3,"bg.jpg")
//bg
createsprite(1,3)
setspritesize(1,100,100)
// solo button

AddVirtualButton( 1, 25, 80, 30)
SetVirtualButtonAlpha(1,255)
SetVirtualButtonImageUp(1,1)
SetVirtualButtonImagedown(1,1)
SetVirtualButtonActive(1,1)

//two player button

AddVirtualButton( 2, 75, 80, 30)
SetVirtualButtonAlpha(1,255)
SetVirtualButtonImageUp(2,2)
SetVirtualButtonImagedown(2,2)
SetVirtualButtonActive(2,1)
//solo play

if GetVirtualButtonreleased(1)
SetVirtualButtonVisible( 1, 0 )
SetVirtualButtonVisible( 2, 0 )
endif

do



Sync()
loop

Currently, nothing happens when I press button 1. Thanks for the help!!
BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 13th Feb 2015 09:28
You need to put your button-checking routine in the game loop (do/loop)
AGK is not event-driven, so you can't tell it to do something once. It needs to be instructed every loop.



Quidquid latine dictum sit, altum sonatur

Login to post a reply

Server time is: 2019-06-20 00:03:33
Your offset time is: 2019-06-20 00:03:33