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
+ Code SnippetFunction PlayerNumberSelection() // PLAYER NUMBER SELECTION SCREEN FUNCTION START
SetScreen()
VwinW = GetVirtualWidth()
VwinH = GetVirtualHeight()
LoadImageResized(1, "football.png", 0.5, 1.0, 0) // load background image
CreateSprite(1, 1)
SetSpriteSize(1, 1024, 768)
SetSpritePosition(1, 0, 0) // set background sprite postion
CreateText(1, "SELECT NUMBER OF PLAYERS") // create the text used at the top of the menu
SetTextSize(1, 70) // set text size
SetTextBold(1, 1) // set text to bold
SetTextColor(1, 250, 250, 0, 255) // set text color
TextW = GetTextTotalWidth(1)
SetTextPosition(1, VwinW / 2 - TextW / 2, 50)
Timer# = Timer() // set timer variable
Repeat // start repeat until loop
MouseLocation()
Sync() // sync or refresh the screen
Until Timer# + 5 <= Timer() // end of the repeat until loop
DeleteText(1)
DeleteImage(1)
DeleteSprite(1)
ClearScreen()
EndFunction
Function MouseLocation()
OldMouseX = MouseX
OldMouseY = MouseY
MouseX = GetRawMouseX()
MouseY = GetRawMouseY()
PrintC("MouseX ") : Print(MouseX)
PrintC("MouseY ") : Print(MouseY)
ResetTimer()
EndFunction
Second menu
+ Code SnippetFunction TeamRoster()
SetScreen()
LoadImageResized(1, "football.png", 0.5, 1.0, 0) // LOAD MENU BACKGROUND
CreateSprite(1, 1)
SetSpriteSize(1, 1024, 768) // CREATE A SPRITE TO SHOW ON SCREEN
SetSpritePosition(1, 0, 0) // SET THE POSITION OF THE SPRITE
CreateText(1, "TEAM ROSTER") // MENU TITLE
SetTextSize(1, 50) // SET THE TITLE TEXT SIZE
SetTextColor(1, 0, 0, 0, 255) // SET THE TITLE TEXT COLOR
SetTextBold(1, 1) // SET TEXT TO BOLD
TextW = GetTextTotalWidth(1) // GET TOTAL WIDTH OF THE TEXT OBJECT
SetTextPosition(1, VwinW / 2 - TextW / 2, 20) // FIND LOCATION ON SCREEN TO POSITION TEXT AND PLACE IT
// TEMPORARY TIMER JUST TO SET MENUS UP. WE NEED TO REPLACE WITH PROPER INPUT DETECTION
Timer# = Timer()
Repeat
Sync()
Until Timer# + 10 <= Timer()
ResetTimer()
DeleteText(1)
DeleteSprite(1)
DeleteImage(1)
EndFunction