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.

AppGameKit Classic Chat / [SOLVED] Working with Virtual Buttons

Author
Message
badkneecap
14
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 13th Jun 2020 16:19
I started working with virtual buttons while I build out my game. I like it because I'm not good with graphics and I can quickly place a button and interact with it. I preload all my buttons and leave them all inactive and invisible state until I'm ready to use them. I have a script that gets called when the user wants to display the "Instructions" for the game. It just pages back and forth between images. When the script runs, it activates and makes them visible. I then loop and check for the user to press the back, forward or exit buttons. Here is my code:



For the most part, it works. When I first load, the "previous" button is not activated. As I page through I check if I am at the first page or last and activate/deactivate buttons to prevent the user from going past the page boundaries. The problem starts when I reach page 1 or page 10. It seems to get stuck on that page. If I reach the past page and click "Previous", it flickers and stays on that page and the "Next" button disappears. It's as if the "Next" button is still pressed. I say it "flickers" because it looks like it first goes to the previous page and then goes back to the next page, essentially staying on that last page. I'm wondering if I'm "deactvating" the button before it completes the full action of "down" and "up". Maybe it's stuck "down". Is there a way to clear the action on a virtual button?

The author of this post has marked a post as an answer.

Go to answer

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 13th Jun 2020 18:18 Edited at: 13th Jun 2020 18:55
This post has been marked by the post author as the answer.
vbuttons are finicky/may not do what you expect. if you're looking for a single press, you'll do well to wait for its release before triggering the action:

edit: removed the hack i had used in some old code, added proper release above.
badkneecap
14
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 14th Jun 2020 14:43
I tried this and it worked (as simple as it was). Thanks for the quick response.

Login to post a reply

Server time is: 2024-11-25 06:02:48
Your offset time is: 2024-11-25 06:02:48