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 / Multiple button dection changes the image as wanted, but won't exit

Author
Message
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 7th Jan 2024 23:45 Edited at: 8th Jan 2024 01:09
Hi,
1. The program loads 68 images numbered 1 to 68 and there are 2 for each button(Up and Down image)
2. program adds 34 virtual buttons numbered 1 to 34 and sets the image to up unless the button is disabed(disabled button has image down set)

I have a screen 1200x800 with 34 buttons and here is my following inside the do / loop to change the image of the buttons and then exit and move on to the next screen. The images change when buttons are pressed, but as soon as the buttons are released the button up is reset. What am I doing wrong?
I actually need things loaded into an array to track things and to save file information later for each player account, but I haven't tried to do that because I am not good with arrays.

[Edit] I removed the sync() inside the for/next loop to get rid of the screen flicker. I also removed the If Btn > 0 endif statement

ASRock motherboard/ AMD 4.1 Ghtz Duel core/16GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 8th Jan 2024 01:38 Edited at: 8th Jan 2024 01:57
i think you're wanting more of a toggle switch function than a Virtual Button. but, you're swapping 1 image for another and not both?

i'm obviously not following completely, and this isnt as perfect as i'd like, but might help:


i just re-read the title here and your use of Exit is exiting the for/next loop . ie, if a specific vbutton is pressed, the remaining vbuttons are not checked in that Do/Loop (which there is nothing set to prompt it to leave).

if you want to exit THAT loop, the exit needs to be outside of the For/Next or some other way.

otherwise, i see no other screen for you to move on to but i think i better understand now that i've re-read so maybe within the For/Next, if a button is Pressed, set a Flag. then outside of the For/Next do something like:

which will kick you outside of the Do/Loop

now, again, looking at your code. if you're not toggling like i first thought, once you set a button's up and down images, there is no need for you to set anything where the vbutton will automatically use whichever image is assigned to each state.

yup. i'm confused on what ur trying to do. sorry about that
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 8th Jan 2024 02:05
Quote: "Virtual Nomad said:

i think you're wanting more of a toggle switch function than a Virtual Button? ie, you're swapping 1 image for nother but not both?"


The buttons basically are toggle switches, but the program deletes everything on the screen and moves to the next screen if one of the 20 team buttons is selected. The other 14 buttons are navigation buttons between the different leagues and divisions of each league.

So, buttons 1 to 20 are the team buttons. If a division in any league has more or less teams than 20, buttons will be added or removed for that division.

The only way the navigation buttons are deleted is if a team button is pressed, otherwise they stay visible/ usable until a team is selected from a league. Then the program advances to the next screen.

I will give your code a try tomorrow after work and post results
ASRock motherboard/ AMD 4.1 Ghtz Duel core/16GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 8th Jan 2024 02:31 Edited at: 8th Jan 2024 10:57
Below is working code although I am not sure if I want to do it that way. It seems so basic (no pun intended).
I also uploaded an image of what the screen looks like.

[Edit] I don't have the other leagues/divisions set up yet in the code so I can't try the navigation buttons other than making it exit for now.

I still would like to try your code Virtual Nomad simply because I need to keep track of things for the user accounts

ASRock motherboard/ AMD 4.1 Ghtz Duel core/16GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.

Attachments

Login to view attachments
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 8th Jan 2024 03:52 Edited at: 8th Jan 2024 03:53
UG,

i have a Tower Defense tutorial project that you might find useful where it includes some array handling of user defined types along with some save/load functionality & i believe more that could/would be pertinent for your project.

the original thread HERE where the most-current version is kept on itch.io HERE.

the total project is ~550 lines of code which i believe reads pretty easily while including considerable commentary throughout.
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 8th Jan 2024 11:34 Edited at: 8th Jan 2024 11:34
Quote: "Virtual Nomad said:

i have a Tower Defense tutorial project that you might find useful where it includes some array handling of user defined types along with some save/load functionality & i believe more that could/would be pertinent for your project.

the original thread HERE where the most-current version is kept on itch.io HERE.

the total project is ~550 lines of code which i believe reads pretty easily while including considerable commentary throughout."


Thank you Virtual Nomad, I will definitely take a look at it after work today. From the looks of it I should be able to learn something from it.
ASRock motherboard/ AMD 4.1 Ghtz Duel core/16GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.
Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 16th Jan 2024 14:48
I change the visibility of a button when disabled.
I have no need to see a button that is not currently functional.
Then, there is no mistake of which button is taking hits, or if the button is not disabled.

I never do all of the buttons in a loop unless enabling or disabling them all, instead of conditions in a loop.
The buttons are endabled/visible or disabled/not visible individually in functions as needed.
Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 17th Jan 2024 17:33
Quote: " Conjured Entertainment said:
I change the visibility of a button when disabled.
I have no need to see a button that is not currently functional.
Then, there is no mistake of which button is taking hits, or if the button is not disabled.

I never do all of the buttons in a loop unless enabling or disabling them all, instead of conditions in a loop.
The buttons are endabled/visible or disabled/not visible individually in functions as needed."


I have changed from running all buttons through one loop to a seperate if/endif statement for each. For now it works better that way, but a lot more code typing or copy/pasting and edit for each button lol.
I think I will try to change visibility of a button when I disable it instead of change to a darker image when disabling it. That should reduce my exe file size.

I need to show the disabled button because it indicates which screen you are currently in or what options(toggle switches) is turned on or off.
ASRock motherboard/ AMD 4.1 Ghtz Duel core/16GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 20th Jan 2024 10:54
Quote: "
Conjured Entertainment said:
I never do all of the buttons in a loop unless enabling or disabling them all, instead of conditions in a loop.
The buttons are endabled/visible or disabled/not visible individually in functions as needed."


After I worked with all of them in a loop I realized it wasn't going to work with how I need things.

@Virtual Nomad
Thank you for the snippet example above. I would like to modify it and use it in my game. I have learned some things from it, but it is still kinda confusing to figure out how to modify to fit what I need. Example: I need to use images with the virtual buttons because using SetVirtualButtonText() the font is to small, plus with the size of buttons I need the virtual buttons look stupid without using images to change the look and have bigger fonts.

I have chosen to use sprites as buttons for now instead of virtual buttons because I am having problems getting certain virtual buttons to work correctly when I know the code is correct. Some buttons you have to click twice to get it to do what it is suppose to do.

Using sprites is so far working perfectly. As I convert each button to sprites I test it and so far so good.

ASRock motherboard/ AMD 4.1 Ghtz Duel core/16GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.

Login to post a reply

Server time is: 2024-04-28 16:49:32
Your offset time is: 2024-04-28 16:49:32