.hits()

Returns whether this stamp or text object "hits" something else, meaning it overlaps with it.

If you pass in another stamp, it returns true if they overlap, or false if they do not.

You can also check whether or not a stamp and text object overlap.

Or see if two text objects overlap.

You can do all of these comparisons with circles, as well. Here's an example app where dragging on the screen moves a small circle around. Any time it hits the large circle, the text or the stamp, the button in the top left of the screen goes from red to green.

If you want to check a lot of stamps at once, you can pass in the name you're wanting to test. You'll get back an array of the things your stamp collides with, or false if you don't collide with anything. Note: you cannot search for text objects in the same way.

Or, you can check a specific x,y location to see if that point overlaps with your stamp, text object, or circle. Here's a program that explodes the monkey if you touch it, or rotates the word 'ape' if you touch that, or causes a circle to dance if you touch that.

Sometimes it may look like the stamps aren't overlapping, but .hits will still return true. That's because every stamp has a square "hit box". For stamps that are taller than they are wide, or vice-versa, intersections between what looks like blank space can still count as a hit. In this example, the rocket and the asteroid are intersecting, even though it looks like they're not.