0
我認爲這應該很容易做到,但我找不到任何解決方案。它總是隻有system.enable("multitouch")
,然後用setFocus()方法。 我有一個右鍵,它對觸摸事件做出響應,並使玩家在舉行時能夠正確運行。然後,我有一個跳轉按鈕,響應輕擊事件,讓玩家跳躍。 跑步的作品,跳躍的作品,但是當我跑步和嘗試跳躍什麼都沒有發生。 下面是一些代碼:Corona SDK多點觸控跑步和跳躍
local speed = 3
local motionx = 0
-- When right arrow is touched, move character right
function right:touch()
if string.find(player.sequence,"jump") then
player:setSequence("jumpRight")
motionx = speed;
elseif string.find(player.sequence,"duck") then
player:setSequence("duckRight")
else
player:setSequence("goingRight")
motionx = speed;
end
player:play()
end
right:addEventListener("touch",right)
-- When up arrow is tapped, jump character
function jump:tap()
if not isJumping then
if string.find(player.sequence, "goingRight") then
isJumping = true
player:setSequence("jumpRight")
player:setLinearVelocity(0,-120)
end
if string.find(player.sequence, "goingLeft") then
isJumping = true
player:setSequence("jumpLeft")
player:setLinearVelocity(0,-120)
end
if string.find(player.sequence, "duckLeft") then
player:setSequence("goingLeft")
end
if string.find(player.sequence, "duckRight") then
player:setSequence("goingRight")
end
player:play()
end
end
jump:addEventListener("tap",jump)
-- Move character
local function movePlayer (event)
player.x = player.x + motionx;
end
Runtime:addEventListener("enterFrame", movePlayer)
我不knowh在哪裏,如何或爲何我應該使用SetFocus()方法。但是到目前爲止,當我發佈右鍵時,我無法跳轉。