What I did was detect whether I was on a portable device first in a startup function (something like this):
function handleStartUp(app_tit AS string)
// set up some globals
global g_on_ios AS integer
global g_on_port AS integer
global spl_img AS integer
global spl_spr AS integer
// assume on an iOS portable
g_on_ios = 1
g_on_port = 1
// determine whether on an iOS platform and on portable
plat$ = left(Lower(GetDeviceName()),3)
if plat$ <> "ios" then g_on_ios = 0
if (plat$ = "win") or (plat$ = "mac") then g_on_port = 0
// set the title
SetWindowTitle(app_tit)
// set a default resolution (for landscape iPhone)
SetVirtualResolution(960,640)
// set up for only one landscape
SetOrientationAllowed(0,0,0,1)
// display our splash
spl_img = LoadImage("/media/mysplash.png")
spl_spr = CreateSprite(spl_img)
SetSpritePosition(spl_spr,0,0)
SetSpriteSize(spl_spr,960,640)
// double sync needed to make sure the backbuffer gets displayed
sync()
sync()
// delay a bit
sleep(500)
endfunction
After everything is loaded, clear the splash screen:
function deleteTheSprite(id)
if (id > 0) AND GetSpriteExists(id) then DeleteSprite(id)
endfunction
function deleteTheImage(id)
if (id > 0) AND GetImageExists(id) then DeleteImage(id)
endfunction
function cleanStartUp()
// clear the splash screen
DeleteTheSprite(spl_spr)
DeleteTheImage(spl_img)
endfunction
When I needed to get some input I'd build my first input box, located to make sure that a pop-up keyboard won't cover it (a prompt and a button would be next to the box and the button would be labeled something like 'press to submit'):
i_input = CreateEditBox()
SetEditBoxPosition(i_input,px#,py#)
SetEditBoxSize(i_input,400,30)
SetEditBoxTextSize(i_input,30)
SetEditBoxDepth(i_input,0)
Then I'd loop until I had a non-blank value:
// process until we have a name
while user_name = ""
// set the initial text
SetEditBoxText(i_input,"")
SetEditBoxActive(i_input,1)
// add a button to press
y# = i_by + 80
x# = i_bx + 40 + GetTextTotalWidth(i_prmpt) + 140
makeAButton(0,1,140,x#,y#,"Submit Name ")
// get the users player name
while user_name = ""
// if we are on portable device
if g_on_port = 1
StartTextInput()
while GetTextInputCompleted() = 0 : Sync() : endwhile
SetEditBoxText(i_input,GetTextInput())
endif
// wait for button pressed
while GetVirtualButtonPressed(1) = 0 : Sync() : endwhile
// get the value
user_name = GetEditBoxText(i_input)
// clear the button
while GetVirtualButtonPressed(1)=1:Sync():endwhile
endwhile
The 'makeAButton' creates a square sprite with text in front of it and places a virtual button on top of it (invisible).
Obviously you'd need to come up with values for some of the variables used to position things (px#,py#,i_bx,i_by were all calculated based on lots of stuff not shown in these snippets).
This has the affect of manually popping up the 'old' edit box on top of everything and accepting input when the user presses the 'done' or 'enter' key on the virtual keyboard.
I had this working very well with my WIP game.
Cheers,
Ancient Lady
AGK Community Tester