我正在尝试使用电晕SDK制作游戏。
游戏大约有3个按钮,玩家需要按特定排列按下它们(1 ==> 2 ==> 3)。如果玩家除了那个安排中的按钮以外的任何地方都会碰到他,他就会失去生命。
我的问题在第二部分。我怎样才能做到这一点。 任何建议请。
Thnx提前。
答案 0 :(得分:0)
尝试(未经测试)
numberOfTouch = 0
match = {1, 2, 3}
...
button1.id = 1
button2.id = 2
button3.id = 3
...
local function mylistener(event)
local phase = event.phase
local target = event.target
numberOfTouch = numberOfTouch + 1
if phase == "began" then
if match[numberOfTouch] == target.id then
if #match == numberOfTouch then
-- You win
end
else
-- You lose
end
end
return true -- to stop propagate event to more objects
end
...
button1:addEventListener("touch", mylistener)
button2:addEventListener("touch", mylistener)
button3:addEventListener("touch", mylistener)