【发布时间】:2013-07-24 09:24:57
【问题描述】:
我又遇到了一个问题。所以,我正在电晕中制作游戏。我希望对象沿直线移动到触摸坐标。我知道我可以简单地使用transition.to() 函数,但物理引擎在转换期间无法正常工作。我编写了以下代码,但当然,圆圈不会直线移动。
function controls(event)
if event.phase == "began" or event.phase == "moved" then
follow = true
touchX = event.x; touchY = event.y
end
if event.phase == "ended" then
follow = false
end
end
function playerMotion()
if follow == true then
if circle.y < touchY then
circle.y = circle.y + 1
elseif circle.y > touchY then
circle.y = circle.y - 1
end
if circle.x < touchX then
circle.x = circle.x + 1
elseif circle.x > touchX then
circle.x = circle.x - 1
end
end
end
希望我的问题足够清楚。
【问题讨论】: