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 Studio Chat / Multiple scenes and duplicated button id's

Author
Message
YarSnez
21
Years of Service
User Offline
Joined: 9th Apr 2003
Location:
Posted: 15th Jun 2021 09:26
Hi,

After a long break from programming have started tinkering again with AGKS.

I've come across an issue which I have a work-around for, but thought I would run it past people for comment.

Have been writing a program and using a scene to create a menu offering options for the game. This works well in that the user selects a required option by clicking on a virtual button and then I switch back to the game scene. I also have another scene acting as a confirmation dialog with Yes and No virtual buttons. The problem I face with this approach is that each scene starts the virtual button IDs from 1, so end up with runtime errors indicating buttons already exist. I can understand why this decision was made, most games wont need to have multiple scenes active. I tried changing the button Id's but AGKS reverts them back again. What I have found is that if the scene file is removed from the project I can then manually update the button IDs and the program will then work. This is of course is not ideal, as the scene once outside of the project can no longer be edited in the 2D designer. If it's later added back into the project, all the button IDs are then automatically renumbered.

I could create a sprite window with buttons, etc. But it's very convenient to use a scene and the 2D designer, but maybe I'm just going about this in the wrong way.

What would be nice is an option to have button IDs continue on from the last used ID from the previous scene.

I have very simple tastes, I am always satisfied with the very best.

Oscar Wilde.
Pfaber1
6
Years of Service
User Offline
Joined: 7th Jan 2018
Location: England
Posted: 15th Jun 2021 12:04
How long did you take a break from programming . I took a year off between Feb 2020 to Feb 2021 and it took me a little while to get into it. I personally would use a large sprite to do what your suggesting but you have got more experience than me . When I do menus with virtual buttons that is the route I take .
YarSnez
21
Years of Service
User Offline
Joined: 9th Apr 2003
Location:
Posted: 15th Jun 2021 14:19
Well, Windows programming was my career, but had to give that up in 2015 for family reasons. However, have dabbled on and off since then. I really meant had not touched AGKS for a couple of years.

I'm just dabbling at the moment and using scenes with the 2D designer to create menus and confirmation screens is very easy and convenient. This way, I can concentrate on the meat of the project without worrying too much about the user interface. This is something that can always be re-done later, if needed.

As said, I realize that scenes have been designed to be the levels of a game, and so would not normally persist, and replicated button IDs would not be a problem. However, some programs don't always require multiple scenes, such as logic games like chess, or card games etc. It all depends on what the programmer wants to do of course.

For fancier menus that overlay the game scene, then sprites are the way to go.
I have very simple tastes, I am always satisfied with the very best.

Oscar Wilde.
PartTimeCoder
AGK Tool Maker
9
Years of Service
Recently Online
Joined: 9th Mar 2015
Location: London UK
Posted: 15th Jun 2021 14:45
When I first read this I thought "just assign a variable" but also thought "I'd better check this first", and indeed it seems this is a mute point as the button ID is hard coded even when a variable is assigned the static id is assigned to the variable and counter resets on a new scene.

I would say report this on Git but someone will say its not a bug its a feature so I'll save myself the typing time, many small things like this have gone ignored for so long, I despair sometimes at the lack of foresight.

1 use case for scenes, menu systems, I have a project that uses a bunch of scenes that work together and are designed to be shown at the same time or on their own (depending on the action or game state), for this I used sprites so did not encounter this issue but did encounter the issue of Text and Edit objects not setting the array variable, if I had used buttons then the whole thing would have broke, it seems the UI was tested with scenes being a single use component rather than layers you can stack to build a master scene from sub scenes.
YarSnez
21
Years of Service
User Offline
Joined: 9th Apr 2003
Location:
Posted: 15th Jun 2021 15:32
Yes, the problem does appear to only be with the button IDs. I was thinking this not necessarily as a bug but more of a design feature. I have followed the forum guidelines and posted this as a question first before possibly posting a suggestion.

The work-around of removing the scene from the project, thus removing the auto ID numbering, works, but it's a little disappointing. A really nice feature would be an option to enable/disable button IDs carrying on from the previous scene.

Maybe I should ignore the provided buttons and just use sprites, but it seems a shame as the Virtual Buttons are very convenient. I'll see if anyone else agrees/disagrees before posting as a suggestion. This is by no means a show stopper and AGK(S) is very good.
I have very simple tastes, I am always satisfied with the very best.

Oscar Wilde.
PartTimeCoder
AGK Tool Maker
9
Years of Service
Recently Online
Joined: 9th Mar 2015
Location: London UK
Posted: 15th Jun 2021 15:42
Well to be honest the inbuilt buttons are a bit naff anyway, its hard to get the text to look right and they ugly as hell, I think they are literally a quick temp solution, I need a button now but don't have a sprite to hand - kind of thing.

its easy enough to make a fancy button but when in the code I just want to code, not "I need to test this function, open Paint.net!!!"

So yeah the button has its uses and is fine for a single scene.
YarSnez
21
Years of Service
User Offline
Joined: 9th Apr 2003
Location:
Posted: 15th Jun 2021 15:51
The Virtual buttons are ugly until assigned different up and down images, but I agree about trying to get the text looking good.
I have very simple tastes, I am always satisfied with the very best.

Oscar Wilde.

Login to post a reply

Server time is: 2024-04-25 21:53:48
Your offset time is: 2024-04-25 21:53:48