此函数可用于设置精灵的边界框值。提供要使用的精灵索引,然后提供边界框位置的左侧、顶部、右侧和底部值。位置是绝对值,其中(0,0)位置对应于精灵的左上角,与精灵的偏移、sprite可能具有的任何“空”像素或在房间中绘制的位置无关。
注意此函数影响sprite资源,以便此精灵的所有其他实例将具有相同的边界框。
sprite_set_bbox(ind, left, top, right, bottom);
参数 | 类型 | 描述 |
---|---|---|
ind | Sprite Asset | 要设置边界框的精灵的索引。 |
left | Real | 边界框的左侧 |
top | Real | 边界框的顶部。 |
right | Real | 边界框的右侧 |
bottom | Real | 边界框的底部。 |
N/A
if (sprite_get_bbox_mode(sprite_index) == 2)
{
left = irandom(sprite_width / 2);
right = irandom((sprite_width / 2) + irandom(sprite_width / 2));
top = irandom(sprite_height / 2);
bottom = irandom((sprite_height / 2) + irandom(sprite_height / 2));
sprite_set_bbox(sprite_index, left, top, right, bottom);
}
上面的代码将检查指定给sprite_索引的精灵的边界框模式,如果设置为手动,则将更改其边界框。