Hello,
I'm a spanish user and i'm not so good speaking English so please first apologize me.
In the past, I ordered DarkBasic Pro and programm a lot of staff a few years ago. Now I recently purchase the AppGameKit Basic and I was testing it. One of my 'experiment' was to creat a function to make buttons. I already did it in DBPro so I think that it will be easy. But I was wrong.
This is my function in DBPro
(HacerBoton = Make Button / PulsarBoton = Press Button)
FUNCTION HacerBoton(PosX,PosY,SizeX,SizeY,texto$)
INK RGB(160,160,160),0 : BOX PosX,PosY,PosX+SizeX,PosY+SizeY
INK RGB(192,192,192),0 : BOX PosX+2,PosY+2,PosX+SizeX-2,PosY+SizeY-2
INK RGB(255,255,255),0 : CENTER TEXT PosX+(SizeX/2),PosY+(SizeY/2-(Text Size()/2)),texto$
ENDFUNCTION
FUNCTION PulsarBoton(PosX,PosY,SizeX,SizeY,texto$)
INK RGB(150,150,150),0 : BOX PosX,PosY,PosX+SizeX,PosY+SizeY
INK RGB(182,182,182),0 : BOX PosX+2,PosY+2,PosX+SizeX-2,PosY+SizeY-2
INK RGB(205,205,205),0 : CENTER TEXT PosX+(SizeX/2),PosY+(SizeY/2-(Text Size()/2)),texto$
IF mouseclick()=1
DO
IF mouseclick()=0 THEN EXIT
LOOP
ENDIF
Time=Timer()
DO
IF Timer()>Time+50 THEN EXIT
LOOP
INK RGB(160,160,160),0 : BOX PosX,PosY,PosX+SizeX,PosY+SizeY
INK RGB(192,192,192),0 : BOX PosX+2,PosY+2,PosX+SizeX-2,PosY+SizeY-2
INK RGB(255,255,255),0 : CENTER TEXT PosX+(SizeX/2),PosY+(SizeY/2-(Text Size()/2)),texto$
IF Scroll<1 THEN Scroll=1
IF Scroll>NumScroll THEN Scroll=NumScroll
ENDFUNCTION Scroll
But I have a lot of trouble converting this into AGK. I'm only trying to convert the first function (HacerBoton) but I have one problem. If I fill the box, the text won't appear above the screen. If I don't fill it, the function work perfectly. So my question is: how can I solve this problem? I want the text above the filled box.
// Created: 2017-03-05
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Button" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
do
HacerBoton(30,30,300,120,1,"Hii!!!")
Sync()
loop
FUNCTION HacerBoton(X,Y,X2,Y2,numboton,texto$)
DrawBox(X,Y,X2,Y2,MakeColor(160,160,160),MakeColor(160,160,160),MakeColor(160,160,160),MakeColor(160,160,160),0)
DrawBox(X+2,Y+2,X2-2,Y2-2,MakeColor(192,192,192),MakeColor(192,192,192),MakeColor(192,192,192),MakeColor(192,192,192),0)
IF GetTextExists(numboton+10000000)=0 THEN CreateText(numboton+10000000,texto$)
SetTextAlignment(numboton+10000000,1)
SetTextDepth(numboton+10000000,0)
SetTextColor(numboton+10000000,255,255,255,255)
SetTextSize(numboton+10000000,40)
SetTextPosition(numboton+10000000,(X+(X2-X)/2),(Y+(Y2-Y)/2)-GetTextTotalHeight(numboton+10000000)/2)
ENDFUNCTION
I hope had explained myself correctly. Thanks a lot!!