game_common.location
简介
组件接口
类
Location
占用多格坐标的位置
成员变量
| 变量名 | 类型 | 初始值 | 须初始化 | 描述 |
|---|---|---|---|---|
| list | array | nil | 可选 | 坐标列表([ x1, y1, x2, y2, ... ]) 为了减少坐标操作的处理,这里记录的是具体坐标 |
成员方法
| 函数原型 | 函数作用 |
|---|---|
| Location new_by_base_offset(int base_y, array offset_list) | 使用基准坐标和一组相对基准坐标的偏移列表创建位置 |
| Location shift(int x_count = 0, int y_count = 0) | 移动位置生成新的位置 |
| array get_base_xy() | 获取基准坐标(以x最小值, y最小值为基准坐标) |
| array get_base_offset() | 获取相对于基准坐标(get_base_xy()获得)的偏移列表 |
| array get_offset(int base_x, int base_y) | 获取相对于指定基准坐标的偏移列表 |
| int count() | 获取坐标数量 |
| void add_xy(int x, int y) | 添加坐标 |
| bool remove_xy(int x, int y) | 移除一个坐标 |
| bool contains_xy(int x0, int y0) | 判断是否包含坐标 |
| bool contains_location(Location other) | 判断是否包含目标位置 |
| bool is_intersecting(Location other) | 判断是否和目标位置相交 |
| bool is_equal(Location other) | 判断是否和目标位置为同一个位置(相等) |
| bool is_congruent(Location other) | 判断是否和目标位置大小和外形一致(不强制要求中心点一致) |
| void iterate_xy(function func) | 遍历所有坐标 |
| bool iterate_xy_until_true(function func) | 遍历所有坐标直到func返回true |
| void iterate_intersect_xy(Location other, function func) | 遍历和目标位置相交部分的坐标 |
| bool iterate_intersect_xy_until_true(Location other, function func) | 遍历和目标位置相交部分的坐标直到坐标满足条件 |
| void iterate_diff_xy(Location other, function func) |