Quote: "hendron said:
Looks like you're checking if the MouseY is less than 256 when it should be 356.
I would highly recommend turning your button code into a reusable function to avoid this kind of mistake. You could probably make it an immediate mode sort of function, like this:"
I corrected the MouseY coordinate code and it still doesn't work. I will try to set variables for the unfilled boxes coordinates that create the clickable button areas and see if I am smart enough to make a reusable function for multiple screens with different amounts of text objects and clickable areas
[Edit] - I just figured out that for some reason it doesn't work if you click inside box with "1" inside, but if I move the mouse up and to the left diagnally some and click it detects the click and moves on to the next screen. Why would it do that if my MouseX and MouseY coordinates are correct? (which they are correct) I verified it more than once to make sure the box coordinates were correct.
First screen code:
// Player Account Include File
`#Include "SelectLeague.agc"
Function PlyrAccount()
`SetScreen()
FileExplore.SetWindowStyle(0x10000000) // || 0x01000000 || 0x80000000) // (WS_VISIBLE | WS_CLIPSIBLINGS | WS_POPUP)
` screen title
CreateText(0,"Select Game Type")
SetTextSize(0,25)
SetTextFont(0,1)
SetTextColor(0,250,12,0,255)
TextW=GetTextTotalWidth(0)
SetTextPosition(0,600- TextW/2,20)
//---------------------------------text above manager button -----------
` every business text
CreateText(1,"Every business")
SetTextSize(1, 12)
SetTextFont(1, 1) // set font to use
SetTextColor(1,255, 255, 255, 255) // set text color
SetTextPosition(1,221,257)
` function controlled text
CreateText(2,"function controlled")
SetTextSize(2, 12)
SetTextFont(2,1) // set font to use
SetTextColor(2, 255,255, 255, 255) // set text color
SetTextPosition(2,190,282)
` by player text
CreateText(3,"by player")
SetTextSize(3, 12)
SetTextFont(3,1) // set font to use
SetTextColor(3, 255,255, 255, 255) // set text color
SetTextPosition(3,247,307)
CreateText(4, "Manager")
SetTextSize(4, 16)
SetTextFont(4, 1)
SetTextColor(4, 255, 0, 0, 255)
SetTextPosition(4, 245, 345)
`----------------------------------text above coach button
CreateText(5,"Every business")
SetTextSize(5, 12)
SetTextFont(5, 1) // set font to use
SetTextColor(5,255, 255, 255, 255) // set text color
SetTextPosition(5,824,257)
CreateText(6,"function controlled")
SetTextSize(6, 12)
SetTextFont(6,1) // set font to use
SetTextColor(6, 255,255, 255, 255) // set text color
SetTextPosition(6,796,282)
CreateText(7,"by computer")
SetTextSize(7, 12)
SetTextFont(7,1) // set font to use
SetTextColor(7, 255,255, 255, 255) // set text color
SetTextPosition(7,842,307)
CreateText(8, "Coach")
SetTextSize(8, 16)
SetTextFont(8, 1)
SetTextColor(8, 255, 0, 0, 255)
SetTextPosition(8, 860, 345)
`----------------------------------------text above Load saved game button
` load saved game text
CreateText(9,"Load saved game")
SetTextSize(9,12)
SetTextFont(9,1)
SetTextColor(9, 255,255, 255, 255)
TextW=GetTextTotalWidth(9)
SetTextPosition(9,600-TextW/2,437)
CreateText(10,"Load saved game")
SetTextSize(10,16)
SetTextFont(10,1)
SetTextColor(10, 255,0, 0, 255)
SetTextPosition(10,505,467)
// PlyrAcct main loop
do
MouseX = GetPointerX()
MouseY = GetPointerY()
print( GameType.length)
DrawBox(1,1,1198,798,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // screen outer frame
//DrawBox(395,45,800,550,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // title frame
DrawBox(172,341,402,364,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // Manager box
DrawBox(775,341,1005,364,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // Coach box
DrawBox(485,463,715,486,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // Load saved game box
// manager text 10
if GetPointerState() = 1
if MouseX > 171 and MouseX <403 and MouseY > 340 and MouseY < 365
SetTextColor(4, 250, 250, 250, 255)
Sync()
Sleep(150)
DeleteTextObjects()
Exit
endif
endif
if GetPointerState() = 1
if MouseX > 775 and MouseX < 1005 and MouseY > 340 and MouseY < 365
SetTextColor(8, 250, 250, 250, 255)
Sync()
Sleep(150)
DeleteTextObjects()
Exit
endif
endif
if GetPointerState() = 1
if MouseX > 485 and MouseX < 715 and MouseY > 463 and MouseY < 486
SetTextColor(10, 250, 250, 250, 255)
Sync()
Sleep(150)
DeleteTextObjects()
Exit
endif
endif
Sync()
loop
PlayerNumberSelection()
EndFunction
function DeleteTextObjects()
for i = 0 to 10
DeleteText(i)
next i
endfunction
Second screen code that isn't working:
// NUMBER OF PLAYERS SELECTION SCREEN FUNCTION-----------------------------------------
Function PlayerNumberSelection() // player number selection function
SetScreen()
WinW = GetWindowWidth()
WinH = GetWindowHeight()
VwinW = GetVirtualWidth()
VwinH = GetVirtualHeight()
CreateText(1, "Select number of players") // create the screen title text
SetTextSize(1, 25) // set text size
SetTextFont(1, 1)
SetTextColor(1, 250, 12, 0, 255) // set text color
SetTextFont(1, 1)
TextW = GetTextTotalWidth(1)
SetTextPosition(1, 600-TextW/2,20)
// screen outer frame
Global LeftFramX = 1
Global RightFramX = 1198
Global TopFramY = 1
Global BottomFramY = 798
// menu frame
Global LeftMenuFramX = 490
Global RightMenuFramX = 760
Global TopMenuFramY = 292
Global BottomMenuFramY = 430
CreateText(2, "1")
SetTextFont(2, 1)
SetTextSize(2, 16)
SetTextColor(2, 255, 255, 255, 255)
SetTextPosition(2, 459, 323)
//AddVirtualButton(1, 495, 330, 50) // button 1
//SetVirtualButtonSize(1,50,50)
//SetVirtualButtonImageUp(1, 2)
CreateText(3, "2")
SetTextFont(3, 1)
SetTextSize(3, 16)
SetTextColor(3, 255, 255, 255, 255)
SetTextPosition(3, 527, 323)
Acct_Num_Plyrs = 0
// main loop
Repeat
print( GameType.length)
DrawBox(LeftFramX,TopFramY,RightFramX,BottomFramY,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // screen outer frame
DrawBox(420,292,760,430,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // small menu frame
DrawBox(440,305,490,355,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // 1 frame
DrawBox(510,305,560,355,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // 2 frame
// Print("Game Type : "+GameType$)
MouseX = GetPointerX()
MouseY = GetPointerY()
print(MouseX)
print(MouseY)
if MouseX < 439 and MouseX < 491 and MouseY < 304 and MouseY < 356
if GetPointerState() = 1
SetTextColor(2, 250, 250, 250, 255)
Sync()
Sleep(150)
DeletePNS()
Acct_Num_Plyrs = 1
Exit
Endif
Endif
Sync()
Until Acct_Num_Plyrs > 0 // end loop
EnterSurName()
EndFunction
Function DeletePNS()
for t = 1 to 3
DeleteText(t)
next t
EndFunction
ASRock motherboard/ AMD 4.1 Ghtz Duel core/16GB 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.