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