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 / Hiding text in select statement

Author
Message
Paronamixxe
AGK Bronze Backer
12
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 4th Dec 2013 23:11 Edited at: 5th Dec 2013 12:52
*RESOLVED*

Hello all! I've hit a rather peculiar snag in which a text is hiding itself when I move to a new case within a select statement. I've pasted the relevant code below. Case 1 does exactly what I want it to do, however, when the "This is the tale of the firestarter" text vanishes and the case is changed to 2 by using
the text totally vanishes?! Its probably just something small that I'm overlooking, but all help is appreciated!

The code that doesn't work...


Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 4th Dec 2013 23:43
I can't see anything wrong with the snippet you posted.
Looks like it would do the following
case 1 --- create text, fade in "This is the tale..." fade out
I assume there is a loop that brings us back to the top of the select statement that you're not showing
Then case 2 -- make text visible, set the new string fade in and then out
Can you show a more complete code snippet? I think the issue is not in these case statements.

Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 5th Dec 2013 01:38
Are you selecting on Cutscene_Flag? Probably not a good idea to change its value inside the case statement. I'm not sure that's the problem, but you should use an exit right after you change the flag.

If you ARE using Cutscene_Flag to just step through the text, then you might consider using something besides select/case.

JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 5th Dec 2013 10:29
More heavyweight compilers would not let you change the case selector inside a case statement. I don't know if AppGameKit Basic drops through (C style) or will only select one statement (Pascal).

-- Jim - When is there going to be a release?
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 5th Dec 2013 11:39 Edited at: 5th Dec 2013 11:40
I use select to control program state.

It runs one and only one case statement each pass. I have not had any problems changing the variable mid case - in fact as it's for program state, there is hardly any code not in a case.

JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 5th Dec 2013 11:59
I just looked at the AppGameKit docs and they do not say whether case statements drop through or not. This rather important information!

-- Jim - When is there going to be a release?
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th Dec 2013 12:27
Just a comment on what others have said about changing the value of the case selector variable. I do it all the time and have never had any compiler complain. Once the case has been selected based on the value when the switch statement is encountered and the endcase is reached (or break or whatever appropriate to the language), the processing drops to the end of the select/switch block. In all compilers (unless you have code errors like missing the end case for the language {way too many times I've lost the 'break' line}) only one case is ever selected and executed. That is the way the system is designed.

Paronamixxe, assuming that you are using Cutscene_Flag as the selector, are you running a larger loop that goes back and does the select again? Or are you assuming that the code does fall through and executes the next case after the first one is done (setting Cutscene_Flag to 3)?

Can you show the code around the select/endselect block?

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Paronamixxe
AGK Bronze Backer
12
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 5th Dec 2013 12:51
I have to agree with Ancient Lady and Marl, I use Select Statements regularly to build the backbone of my games, I find the structure really good to work with when it comes to building menus and I've never had a problem with it.

For the record, I fixed the problem... I literally had a completely black sprite covering the screen, and thus my text... So all I had to do was add
and everything works as it should. Noob mistake, sorry guys

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th Dec 2013 13:33
If only all problems were that simple!

Good luck and Happy Programming!

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Paronamixxe
AGK Bronze Backer
12
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 5th Dec 2013 13:42
IKR!

haha, thanks!

Paronamixxe
AGK Bronze Backer
12
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 5th Dec 2013 13:42
oh, and good luck with the move AL!

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Dec 2013 19:48
Quote: "More heavyweight compilers would not let you change the case selector inside a case statement."


I use this method in all of my programs to drive my state machine approach. Wrap it up in a loop as others have mentioned, and it will run just one CASE each iteration.

I don't know if this makes AppGameKit right or wrong, but it works well for me . I have used this approach in VB and .NET before too.

Login to post a reply

Server time is: 2024-11-24 23:43:31
Your offset time is: 2024-11-24 23:43:31