此函数在给定方向上以给定速度加速实例。
这相当于计算给定方向上给定速度的x分量和y分量,然后将它们分别添加到hspeed和vspeed。
如果要简单地设置速度而不是逐渐加速,请使用motion_set()。
motion_add(dir, speed);
参数 | 类型 | 描述 |
---|---|---|
dir | Real | 增加的方向。 |
speed | Real | 增加的速度。 |
N/A
var pdir;
pdir = point_direction(other.x, other.y, x, y);
motion_add(pdir, other.speed);
if speed > 8 speed = 8;
在与另一个对象的碰撞事件中将调用上述代码。它根据碰撞中涉及的其他实例的位置和速度向实例的运动方向和速度添加向量。如果速度超过8(每步像素数),它就会限制速度。