distance_to_point(x, y);
参数 | 描述 |
---|---|
x | The x position to check. |
y | The y position to check. |
返回: Real(实数)
此函数计算从调用实例的边界框的边缘到房间中指定的x / y位置的距离,返回值以像素为单位。请注意,如果调用对象没有精灵或没有定义遮盖,则结果将不正确。
if distance_to_point(obj_Player.x, obj_Player.y) < range
{
canshoot = true;
}
上面的代码将检查到玩家对象x / y位置的距离,如果它小于存储在变量“range”中的值,则变量“canshoot”被设置为true。