我想加速一个玩家在任何角度它指着英寸我试图在电晕游戏引擎,它提供了我们内置的物理引擎。我确实知道加速度是速度和时间的变化率,但我如何将它应用于代码?我怎么加速它在任何角度?如何加速一个特定方向的太空飞船(Corona SDK)
这里是我的尝试:
player.angle = 30
player.speed = 20
player.acceleration = 2
print(player.angle)
local scale_x = math.cos(player.angle)
local scale_y = math.sin(player.angle)
local function acceleratePlayer (event)
if(event.phase=="began") then
player.speed = player.speed + player.acceleration
player.velocity_x = player.speed * scale_x
player.velocity_y = player.speed * scale_y
player.x = player.x + player.velocity_x
player.y = player.y + player.velocity_y
end
end
应该将accelerating_angle与player.angle类似吗?或者我应该将其转换为弧度值? – Nit