Bounds is a built-in class in the Mini Micro API. It represents a rectangular bounding box, which can be tested for overlap with other bounding boxes, or for containing a point. This is often used for collision-checking and hit-testing with Sprites.
Methods and properties used with Bounds objects
Use these methods on Sprite instances, created with
|Method or Property||Purpose|
|Bounds.x||horizontal center of the bounds|
|Bounds.y||vertical center of the bounds|
|Bounds.width||bounding box width|
|Bounds.height||bounding box height|
|Bounds.rotation||bounding box rotation (degrees counter-clockwise)|
|Bounds.corners||returns bounding box corners as a list of |
|Bounds.overlaps(b)||return whether this bounds overlaps bounds b|
|Bounds.contains(x, y)||return whether the bounds contains the given point|
The following example defines a Bounds at the center of the screen, and then enters a loop which draws the bounds yellow when the mouse is over it, and gray when it is not.
b = new Bounds b.x = 480 b.y = 320 b.width = 200 b.height = 100 b.rotation = 45 while true if b.contains(mouse) then gfx.drawPoly b.corners, color.yellow else gfx.drawPoly b.corners, color.gray end if yield end while
See also: How to detect a click on a sprite