게임 개체를 터치 위치로 이동하려고합니다. 나는 그것을하는 수많은 다른 방법을 시도했지만, 아무 소용이 없습니다. 전 프레임을 계속 움직이게하기 위해 모든 프레임마다 개체의 위치를 업데이트하고 있습니다. 힘이 추가되는지 여부가 영향을 받는지 확실하지 않습니다.개체를 터치 위치로 이동 - Corona SDK
local function attack(xPos,yPos)
--get magnitude of touch vector
local magnitude = math.sqrt(xPos*2 + yPos*2)
--normalize vector
xPos = xPos/magnitude
yPos = yPos/magnitude
print(xPos..yPos)
local forceMag = 0.1 -- change this value to apply more or less force
--now apply the force
crow:setLinearVelocity(xPos*forceMag, yPos*forceMag)
--crow:applyLinearImpulse(xPos*forceMag, yPos*forceMag, crow.x, crow.y)
end
local function touchHandler(event)
if (event.phase == "began") then
end
if (event.phase == "ended") then
if (event.yStart>event.y+10) then
jump()
else attack(event.x,event.y) end
end
end
: 나는 터치 위치로 이동 까마귀를 얻으려고 곳
crow:translate((platformSpeed),0)
을 그리고 여기에 있습니다 : 여기
내가 (업데이트 함수 내에서) 까마귀를 이동 곳이다
아시다시피, 나는 선형 속도와 선형 임펄스를 시도해 왔지만 방향은 항상 잘못되었습니다!
도움이 될 것입니다. 감사합니다. Alan.
내가 나에게 조금 도움이되는이 발견 : [각도를 밖으로 작동하지 Player를 클릭하여 관련 촬영을 (http://forums.coronalabs.com/topic/33806-working-out-an 쏘기 관련성이있는 클릭 관련성이없는 플레이어 /) – Alan