Hi,
I am trying to create a world selection screen, I have taken some code I found on here and used it, it is kind of ok, but seems a little buggy and I don’t like the click event as it seems to fire at the wrong time, can anyone see any problems or suggest anything better? I tried the slideview from corona but I didn’t want a slide per screen.
[lua]-- LOAD MENUS
local menus = {}
local xPosHandler = {}
local function handleTouch(e)
local phase = e.phase
local t = e.target
if “began” == phase then
t.clicked=true
for i=1,#worlds do
xPosHandler[i] = e.x - menus[i].x
end
display.getCurrentStage():setFocus(t)
t.isFocus = true
elseif “moved” == phase and t.isFocus then
t.isFocus=true
for i=1,#worlds do
menus[i].x = e.x - xPosHandler[i]
end
elseif “ended” == phase then
display.getCurrentStage():setFocus(nil)
t.isFocus = true
for i=1,#worlds do
if menus[i].x > 240 - 80 and menus[i].x < 240 + 80 then
diff = menus[i].x - 240
end
end
for i=1,#worlds do
transition.to(menus[i],{x = menus[i].x - diff,time = 500})
end
if t.unlocked==1 then
if t.x > 220 and t.x < 260 then
global.world_id = t.id
director:changeScene(“levelselection”)
end
end
end
end[/lua] [import]uid: 72726 topic_id: 15647 reply_id: 315647[/import]