FROM : Scott Anguish
DATE : Thu Apr 05 21:49:56 2007
On Apr 5, 2007, at 3:01 PM, Fen Soares wrote:
> Therefore, I have an NSView into which I am drawing an array of
> NSImages. I
> would like to be able to move them around by dragging the mouse,
> but feel as
> though extensive mouse and z-index visibility testing is overkill,
> but after
> a good deal of surfing cannot see an alternative.
>
> Is there a well trodden path to maintaining this sprite-like
> behaviour in
> Cocoa?
Absolutely.
You have a single view that displays all the items. and you track the
image rectangles, draw them, and do the hit-testing and dragging
yourself.
There isn't much extensive to it. You simply start at the closest
rectangle and test the bounds against the mouse location. First hit
is the one that you drag.
Have a look at the Views Programming Guide for Cocoa. it has an
example that does just this (although with a single rectangle, but
that is easy to extend)
DATE : Thu Apr 05 21:49:56 2007
On Apr 5, 2007, at 3:01 PM, Fen Soares wrote:
> Therefore, I have an NSView into which I am drawing an array of
> NSImages. I
> would like to be able to move them around by dragging the mouse,
> but feel as
> though extensive mouse and z-index visibility testing is overkill,
> but after
> a good deal of surfing cannot see an alternative.
>
> Is there a well trodden path to maintaining this sprite-like
> behaviour in
> Cocoa?
Absolutely.
You have a single view that displays all the items. and you track the
image rectangles, draw them, and do the hit-testing and dragging
yourself.
There isn't much extensive to it. You simply start at the closest
rectangle and test the bounds against the mouse location. First hit
is the one that you drag.
Have a look at the Views Programming Guide for Cocoa. it has an
example that does just this (although with a single rectangle, but
that is easy to extend)
| Related mails | Author | Date |
|---|---|---|
| Fen Soares | Apr 5, 21:01 | |
| Scott Anguish | Apr 5, 21:49 | |
| I. Savant | Apr 5, 22:01 | |
| Scott Anguish | Apr 5, 22:07 | |
| Scott Anguish | Apr 5, 22:10 | |
| Michael Watson | Apr 5, 22:13 | |
| Michael Watson | Apr 5, 22:14 | |
| I. Savant | Apr 5, 22:16 | |
| Fen Soares | Apr 6, 10:10 |






Cocoa mail archive

