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 / [SOLVED] Finding center of window and center of text formula works in 1st menu but not 2nd menu

Author
Message
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 16th Jan 2022 07:17 Edited at: 16th Jan 2022 07:20
Hi,

I have 2 menu screens that appear one after the other. They both use 1024x768 window and the same formula to place text in the center up top of the screen. It should work, but it doesn't in the 2nd menu, it appears far left. Why?
All functions here are called in order in the main game engine loop code file. So it goes from one menu to the next. Each menu code is in their respective #include file
All variables are declared global in the main game engine code file near the top

The formula in question is


First menu


Second menu
Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB 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.

The author of this post has marked a post as an answer.

Go to answer

Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 16th Jan 2022 09:34 Edited at: 16th Jan 2022 09:34
My guess is that you haven't set VwinW as global. So in your TeamRoster() function it is zero
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 16th Jan 2022 15:26 Edited at: 16th Jan 2022 15:30
Quote: "My guess is that you haven't set VwinW as global. So in your TeamRoster() function it is zero"


Yes, near the top of the main code file VwinW is declared Global



The 2 menu's #Include files are listed there too and they are both obviously not remmed out lol
Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB 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: 16th Jan 2022 15:43 Edited at: 16th Jan 2022 15:44
For some weird reason it it working now. Maybe since I had been working on the game for a long time yesterday I just needed to clear the memory of AGK. I started it up this morning and it worked. Hmm
Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB 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: 16th Jan 2022 16:30
Something weird hmm, The formula works only if both menus are running one after the other, but if I rem out the function call in main code file to the PlayerNumerSelection() then the TeamRoster menu running by itself shows "Team Roster" to the far left. I uploaded a screen shot. Just disreguard all the buttons and other text in the upper left of screen they aren't relevent to the issue. They are there because I use to run the program in 1920x1080 and I'm currently relocating everything for 1024x768
Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB 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
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 16th Jan 2022 17:06
instead of doing this:

It would be easier to place the text in the centre of the screen and centre align the text. Like this:


Also, are you aware that you are using the same ID for both text objects?
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 16th Jan 2022 18:05
Yes, I agree that it would be easier to do as you have suggested. I tried it and it worked before I even started this thread, but I was just trying to set things to variables to allow the screen resolution to be changed in game settings if someone wanted to.

Quote: "
Also, are you aware that you are using the same ID for both text objects? "


Yes, I'm aware that I am using the same ID for both text objects, but at the end of each menu I have it deleting everything including the text objects before it goes to the next menu so the ID should be freed up correct?
Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB 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.
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 16th Jan 2022 18:07
This post has been marked by the post author as the answer.
You're assigning VwinW and VwinH in your PlayerNumberSelection() function but not in your TeamRoster() function
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 16th Jan 2022 18:36
Quote: "You're assigning VwinW and VwinH in your PlayerNumberSelection() function but not in your TeamRoster() function"


Thank you hendron, I didn't know I had to do it for both menus. Maybe I thought since it already was set before TeamRoster() menu that it would adust for the TeamRoster menu because of different text object length.

Thank you that worked. Now I can continue to set the rest of the menu up and not have to run anything but TeamRoster menu so I don't have to wait through previous menus to get to the TeamRoster.
Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB 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.
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 17th Jan 2022 19:30 Edited at: 17th Jan 2022 19:32
Quote: "Thank you hendron, I didn't know I had to do it for both menus. Maybe I thought since it already was set before TeamRoster() menu that it would adust for the TeamRoster menu because of different text object length."


No problem. You were getting the inconsistency you mentioned because if you didn't call PlayerNumberSelection() before TeamRoster(), then VwinW and VwinH were never being set. Personally I would recommend setting the VwinW and VwinH variables once, outside of either of those functions, before they are called.

Login to post a reply

Server time is: 2024-05-01 21:57:42
Your offset time is: 2024-05-01 21:57:42