You can do this using the INTERSECTS or INSIDE function.
1.Intersects
--Checks to see a sprite intersects another
--If the sprite's ink is set to matte it uses the actual outline of the sprite (white pixels are the background). If the ink is anything else it uses the sprite's quad.
--Since collision is based on either the outline or the quad, if the sprites is rotated or skewd, it will still work correctly.
if sprite(1).intersects(2) then
2.Inside
--Checks to see whether a point is inside a rectangle
--Will only return true if the specified point is somewhere inside the rectangle.
--When used with sprites, a collision is only detected when the center of the sprite is somewhere inside the rectangle of another sprite.
--A sprite's rectangle does not reflect rotation or skew changes accurately.
if sprite(1).loc.inside(sprite(2).rect) then
It is quite obvious that the first one is better, but if the second works fine for your situation, use it, it less demanded on the computer.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.