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 / Clear text from screen?

Author
Message
bigtunacan
9
Years of Service
User Offline
Joined: 24th Jul 2015
Location:
Posted: 21st Feb 2016 09:09
I am writing a quiz style app that involves displaying a lot of different text at different times.

I have included most of the current code below. The basic issue is that I have different states [DrawQuestion/DrawAnswerResult] being the two currently worked on.

I start in the DrawQuestion state and this works fine. When the user clicks the submit button then I switch the state to DrawAnswerResult and call hide_question_screen() which sets the current text to not visible and deletes those text objects. After this the program correctly is calling the draw_answer_result function, but it still continues to display the question text that I have tried to remove from the screen.

No idea what I'm doing wrong here.

bigtunacan
9
Years of Service
User Offline
Joined: 24th Jul 2015
Location:
Posted: 21st Feb 2016 09:15 Edited at: 21st Feb 2016 17:42
I have tried working around this by adding
at the top of my draw_answer_result function.
That hid the existing text of my draw_question function, but then I'm not able to display any new text!
Dybing
13
Years of Service
User Offline
Joined: 12th Sep 2011
Location: Bergen, Norway
Posted: 21st Feb 2016 20:37 Edited at: 21st Feb 2016 22:40
Oh, some messy code there. I've taken the liberty of cleaning it up a little - and removed the most glaring bugs. As for the text showing where you want, it is a matter of sprinkling some sync() commands within the currently running loop. Normally you'd get to do all this in the main-loop, but since the routine should be waiting for user input, it need be added somewhere within that scope. So I made a sub-loop where it is waiting for user input, and syncing at the same time.


Mind you, I have not compiled this - I don't have the supporting files. So some typos should be expected

Keeping ones code clean is a virtue. If it is neatly organized and easily readable, it is easy to structure the logic right, and it is easy to hunt down the inevitable bugs. So-called work-arounds is a big no-no. Down the road they tend to introduce more problems than they solve. Doing it properly may require a bit more work initially, but it will save you a ton of work later on.

Login to post a reply

Server time is: 2024-09-29 11:29:02
Your offset time is: 2024-09-29 11:29:02