motion_add

此函数在给定方向上以给定速度加速实例。

这相当于计算给定方向上给定速度的x分量y分量,然后将它们分别添加到hspeedvspeed

如果要简单地设置速度而不是逐渐加速,请使用motion_set()

 

语法:

motion_add(dir, speed);

参数类型描述
dirReal增加的方向。
speedReal增加的速度。

 

返回:

N/A

 

例子:

var pdir;
pdir = point_direction(other.x, other.y, x, y);
motion_add(pdir, other.speed);
if speed > 8 speed = 8;

在与另一个对象的碰撞事件中将调用上述代码。它根据碰撞中涉及的其他实例的位置和速度向实例的运动方向和速度添加向量。如果速度超过8(每步像素数),它就会限制速度。