Two NSRects adjacent/touching?
Two NSRects adjacent/touching?
- Subject: Two NSRects adjacent/touching?
- From: Brad Peterson <email@hidden>
- Date: Wed, 27 Jun 2007 03:29:21 -0700 (PDT)
Hi all,
Summary:
Is there a simple way to determine if two NSRects are
touching/adjacent to each other?
Background:
I'm working on an instructional tile game, and need a
way to determine if tiles are touching.
Currently, I have a tile class, each of which knows
its own NSRect, whether it's been clicked, etc. At the
time of a new game, all of the tiles are created and
stored in an NSMutableArray.
When the game's being played, and the user clicks
somewhere in the view, I iterate through the tile
array to see which one the user clicked, using a
simple NSPointInRect() call.
This is where I'm running into trouble: only some
tiles are clickable at any given moment. Part of what
determines clickability is whether the tile has any
sides that aren't touching another tile.
So, I was hoping to find a way to determine this
programatically by feeding the clicked tile's rect
into a function which could then quickly compare that
rect against those of the other tiles.
Is there an easy way to determine whether two NSRects
are touching/adjacent to each other?
Thanks!
B
____________________________________________________________________________________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden