@Gewis I don’t have time right now to look thru your code, but here’s an example of code I have that shows a menu with buttons that take you to different websites. When you’re in a website and want to get back to the program, press done
in the upper left of the screen. When I run your code, all I get is a blue screen with three words on it, Start, Settings, and Website. Tapping them does nothing. I’ll look thru your code later to see what needs to be done.
EDIT: Sorry, I was in such a hurry I forgot to post the example. Here it is.
displayMode(FULLSCREEN)
function setup()
func=menu -- start screen
buttonTab={} -- buttons table
-- button(x,y,width,height,button name,button screen,button function)
-- buttons that show on the menu screen
table.insert(buttonTab,button(350,600,100,50,"Screen 1",menu,screen1))
table.insert(buttonTab,button(350,500,100,50,"Screen 2",menu,screen2))
table.insert(buttonTab,button(350,400,100,50,"Screen 3",menu,screen3))
table.insert(buttonTab,button(700,50,100,50,"EXIT",menu,close))
-- buttons that show on screen1
table.insert(buttonTab,button(350,600,150,50,"Google",screen1,url1))
table.insert(buttonTab,button(350,500,150,50,"twolivesleft",screen1,url2))
table.insert(buttonTab,button(350,100,150,50,"Menu",screen1,menu))
-- buttons that show on screen2
table.insert(buttonTab,button(350,600,150,50,"map quest",screen2,url3))
table.insert(buttonTab,button(350,100,150,50,"Menu",screen2,menu))
-- buttons that show on screen3
table.insert(buttonTab,button(350,600,150,50,"amazon",screen3,url4))
table.insert(buttonTab,button(350,100,150,50,"Menu",screen3,menu))
end
function draw()
background(40, 40, 50)
fill(255)
func() -- call the function set by the button
end
function touched(t) -- check if a button was pressed
if t.state==BEGAN then
for a,b in ipairs(buttonTab) do
if b:touched(t) then
break
end
end
end
end
function menu()
background(58, 97, 136, 255)
fontSize(30)
text("Menu Screen",350,700)
drawButtonTab()
end
function screen1()
background(101, 43, 43, 255)
fontSize(30)
text("Screen 1",350,700)
drawButtonTab()
end
function screen2()
background(110, 165, 74, 255)
fontSize(30)
text("Screen 2",350,700)
drawButtonTab()
end
function screen3()
background(150, 144, 44, 255)
fontSize(30)
text("Screen 3",350,700)
drawButtonTab()
end
function url1()
openURL('http://www.google.com',true)
func=screen1 -- return to screen1
end
function url2()
openURL('http://twolivesleft.com',true)
func=screen1 -- return to screen2
end
function url3()
openURL('http://www.mapquest.com',true)
func=screen2 -- return to screen3
end
function url4()
openURL('http://www.amazon.com',true)
func=screen3 -- return to screen4
end
function drawButtonTab() -- draw selected buttons from button table
fontSize(20)
for a,b in ipairs(buttonTab) do
b:draw()
end
end
button=class()
function button:init(x,y,w,h,name,screen,func)
self.x=x -- x position
self.y=y -- y position
self.w=w -- width
self.h=h -- height
self.name=name -- name to put on the button
self.screen=screen -- screen to draw the button on
self.func=func -- function to call when the button is pressed
end
function button:draw()
if func==self.screen then -- draw the button
sprite("Cargo Bot:Dialogue Button",self.x,self.y,120)
fill(255, 0, 0, 255)
text(self.name,self.x,self.y)
end
end
function button:touched(t)
if func==self.screen then -- only check current screen button
if t.x>self.x-self.w/2 and t.x<self.x+self.w/2 and
t.y>self.y-self.h/2 and t.y<self.y+self.h/2 then
func=self.func
return true
end
return false
end
end