画面をタップしたままにすると、プレイヤーが Y 方向にスピードを上げていくという問題があります。
私が望むのは、プレーヤーが画面をタップして (そして浮かんでいる間)、一定の速度で (速くなることなく) 上昇することです。
フロート速度とタッチイベントの関数は次のとおりです。
function activateJets(ship,event)
ship:applyForce(0, -1.0, ship.x, ship.y)
print("run")
end
function touchScreen(event)
print("touch")
if event.phase == "began" then
ship.enterFrame = activateJets
Runtime:addEventListener("enterFrame", ship)
end
if event.phase == "ended" then
Runtime:removeEventListener("enterFrame", ship)
end
end
Runtime:addEventListener("touch", touchScreen)
これが意味をなさない場合は申し訳ありません。ここに私が欲しいものの一般的な考えがあります:
- プレーヤーが画面に触れる (そして保持する)
- その後、オブジェクトは一定の速度で浮き上がります (速度の増加なし)
- プレイヤーがタッチを離す
- オブジェクトは正常にドロップします