废话不多说,直接上代码
传入easytouch的园丁偏移值,根据摄像机的旋转,输出变换后的x,y
function fitRoleCamera(joyPositionX,joyPositionY)
if CameraUtils.curCameraType == GameCameraType.Camera_3D then
local camera = CameraUtils.GetCurCamera()
local roleRotate = camera.transform.eulerAngles
local revTan = math.atan(joyPositionX/joyPositionY)
local SkewLength = math.abs(math.sin(revTan) * joyPositionY)
local angle = math.deg(revTan)
angle = angle + roleRotate.y - roleRotate.z
if joyPositionY > 0 then
angle = angle + 180
end
local x = math.sin(math.rad(angle))
local y = math.cos(math.rad(angle))
return x,y
end
end