sprite_set_bbox

此函数可用于设置精灵的边界框值。提供要使用的精灵索引,然后提供边界框位置的左侧、顶部、右侧和底部值。位置是绝对值,其中(0,0)位置对应于精灵的左上角,与精灵的偏移、sprite可能具有的任何“空”像素或在房间中绘制的位置无关。

注意此函数影响sprite资源,以便此精灵的所有其他实例将具有相同的边界框。

 

语法:

sprite_set_bbox(ind, left, top, right, bottom);

参数类型描述
indSprite Asset要设置边界框的精灵的索引。
leftReal边界框的左侧
topReal边界框的顶部。
rightReal边界框的右侧
bottomReal边界框的底部。

 

返回

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_索引的精灵的边界框模式,如果设置为手动,则将更改其边界框。