This function will check a rectangular area that you define to see if it is either not in collision, completely within the destination bounds, or if it is simply touching, a defined circular area. If they are not touching at all the function will return 0, if the source is completely within the destination it will return 1, and if they are simply overlapping then it will return 2. 你可以在下图看到：

rectangle_in_circle(sx1, sy1, sx2, sy2, x, y, rad);

参数 | 描述 |
---|---|

sx1 | The x coordinate of the left side of the source rectangle. |

sy1 | The y coordinate of the top side of the source rectangle. |

sx2 | The x coordinate of the right side of the source rectangle. |

sy2 | The y coordinate of the bottom side of the source rectangle. |

x | The x coordinate of the centre of the circle |

y | The y coordinate of the centre of the circle. |

rad | The x coordinate of the second side of the triangle to check. |

Real（实数）

inst = instance_nearest(x, y, obj_Bullet);

if instance_exists(inst)

{

if rectangle_in_circle(inst.x - 5, inst.y - 5, inst.x + 5, inst.y + 5, x, y - 25, 20) > 0

{

hit = true;

}

}

The above code uses the

rectangle_in_circlefunction to check for a collision within a circular area and the rectangle around a found instance. If there is a collision (either an edge overlap or encompassed) then a variable will be set totrue.