Difference between revisions of "Bounds.contains"

From MiniScript Wiki
Jump to navigation Jump to search
(Created page with "<c>Bounds.contains</c> returns true (1) if the given coordinates are within the bounds, and false (0) if they are outside the bounds. === Arguments === {| class=...")
 
 
Line 7: Line 7:
 
! Parameter Name !! Type !! Default Value !! Meaning
 
! Parameter Name !! Type !! Default Value !! Meaning
 
|-
 
|-
| ''x'' || number || 0 || horizontal position
+
| ''x'' || number || 0 || horizontal position; or a list or map (see below)
 
|-
 
|-
 
| ''y'' || number || 0 || vertical position
 
| ''y'' || number || 0 || vertical position
Line 13: Line 13:
  
 
=== Usage Notes ===
 
=== Usage Notes ===
 +
The <c>contains</c> method may be given <c>x</c> and <c>y</c> as two separate arguments; or it may be given an <c>[x, y]</c> list; or it may be given any map containing "x" and "y" keys (such as [[mouse]]).  If given a list or map, then the second parameter is ignored.
 +
 
The coordinate system is undefined, but the parameters are assumed to be in the same coordinate system as the bounds itself.  So for example, if using this with [[Sprite.localBounds]], then <c>x</c> and <c>y</c> should be coordinates local to the sprite.  But if using it with [[Sprite.worldBounds]], then <c>x</c> and <c>y</c> should be relative to the [[SpriteDisplay|sprite display]] itself.
 
The coordinate system is undefined, but the parameters are assumed to be in the same coordinate system as the bounds itself.  So for example, if using this with [[Sprite.localBounds]], then <c>x</c> and <c>y</c> should be coordinates local to the sprite.  But if using it with [[Sprite.worldBounds]], then <c>x</c> and <c>y</c> should be relative to the [[SpriteDisplay|sprite display]] itself.
  
 
[[Category:Mini Micro]]
 
[[Category:Mini Micro]]

Latest revision as of 16:33, 8 July 2021

Bounds.contains returns true (1) if the given coordinates are within the bounds, and false (0) if they are outside the bounds.

Arguments

Parameter Name Type Default Value Meaning
x number 0 horizontal position; or a list or map (see below)
y number 0 vertical position

Usage Notes

The contains method may be given x and y as two separate arguments; or it may be given an [x, y] list; or it may be given any map containing "x" and "y" keys (such as mouse). If given a list or map, then the second parameter is ignored.

The coordinate system is undefined, but the parameters are assumed to be in the same coordinate system as the bounds itself. So for example, if using this with Sprite.localBounds, then x and y should be coordinates local to the sprite. But if using it with Sprite.worldBounds, then x and y should be relative to the sprite display itself.