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 / having trouble with DeleteText() (Tier 1)

Author
Message
100Megaton
13
Years of Service
User Offline
Joined: 21st Apr 2011
Location:
Posted: 13th Oct 2013 21:46
Hi Folks, I am sure I'm doing something wrong... but I can't for the life of me figure out what. I'm creating a menu using text, when I try to remove that text using DeleteText though, nothing happens. I even tried using ClearScreen() to no avail.

Below is my code. loadMainMenu() is called once, before the main loop begins.



Can someone point me in the correct direction? Any help will be greatly appreciated.
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 14th Oct 2013 00:07 Edited at: 14th Oct 2013 00:09
Firstly, I wouldn't load the font every time the function is called. The code indicated leaves 5 images in memory.

As to the reported problem, the makeMenutext function takes num as a parameter, but doesn't use it - the value of num is replaced by the return from the createText call.

You need to use the other format of CreateText;

The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 14th Oct 2013 00:09
Your problem is that when you create the text with the makeMenuText function, you are letting AppGameKit decide on an ID for the text by doing:


Since you want to assign your own ID, you should be using

or



I can't remember which is the right order

Say ONE stupid thing and it ends up as a forum signature forever. - Neuro Fuzzy
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 14th Oct 2013 00:14 Edited at: 14th Oct 2013 00:15
Someone is asleep at the keyboard, $text is wrong in any format
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 14th Oct 2013 00:17
Well, im not asleep (yet) but I have not been using T1 for a year and I have been doing some PHP latley which has the $ before every variable

Say ONE stupid thing and it ends up as a forum signature forever. - Neuro Fuzzy
100Megaton
13
Years of Service
User Offline
Joined: 21st Apr 2011
Location:
Posted: 14th Oct 2013 13:04
Thank you both! As suggested, I moved the loading of the font image out of that function and into a place where it will be loaded just once, and am instead calling it in the function using SetTextFontImage().

After I switched createText to the format you both suggested, everything worked as intended. Thank you again, I appreciate the help; apparently I'm a bigger noob than I thought I was. >_<
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 14th Oct 2013 16:34 Edited at: 14th Oct 2013 18:08
100megaton, the core problem, as others pointed out, is that you are using the wrong form for CreateText. Use 'CreateText(text$,num)' so that it uses the number you want.

EDIT: Sorry, it should be CreateText(num,text$).

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2024-05-07 14:36:32
Your offset time is: 2024-05-07 14:36:32