Hello,
I have a basic screen where the user can slide through some images (just like the different themes in angry birds and the different boxes in cut the rope). It works perfectly except the user can slide to the left/right even when its the first/last item on the menu. I’m just wondering how to limit the slider. I have tried doing it in several ways but each gave me a different issue. Heres the code:
[lua]local num = 3
local xPosHandler = {}
local function handleTouch(e)
local phase = e.phase
local t = e.target
if “began” == phase then
for i=1,num do
xPosHandler[i] = e.x - menu[i].x
end
display.getCurrentStage():setFocus(t)
t.isFocus = true
elseif “moved” == phase and t.isFocus then
for i=1,num do
menu[i].x = e.x - xPosHandler[i]
menu[i].alpha = 0.3
if menu[i].x > _W/2 - _W/3 and menu[i].x < _W/2 + _W/3 then
menu[i].alpha = 1
end
end
elseif “ended” == phase then
display.getCurrentStage():setFocus(nil)
t.isFocus = false
for i=1,num do
menu[i].alpha = 0.3
if menu[i].x > _W/2 - _W/3 and menu[i].x < _W/2 + _W/3 then
diff = menu[i].x - _W/2
menu[i].alpha = 1
end
end
for i=1,num do
transition.to(menu[i],{x = menu[i].x - diff,time = 500})
end
end
end[/lua]
Where “menu” is a table which has 3 graphics inside it. Thanks. [import]uid: 82699 topic_id: 22489 reply_id: 322489[/import]