Re: Using an NSMatrix subclass for a board game view
Re: Using an NSMatrix subclass for a board game view
- Subject: Re: Using an NSMatrix subclass for a board game view
- From: Stig Brautaset <email@hidden>
- Date: Fri, 12 Oct 2007 20:27:20 +0100
On 12 Oct 2007, at 19:12, Fritz Anderson wrote:
On 12 Oct 2007, at 11:31 AM, Brautaset Stig wrote:
I'm writing a simple Reversi game, and I'm currently struggling a
bit trying to create a simple animation of the pieces being
flipped when a player (or the AI) makes a move. I'm using a
subclass of NSMatrix for my main view, and trying to make it call
its own display routine again.
[snip helpful response]
In the long run, you might want to consider your own board view.
You are already fighting NSMatrix by providing your own mouseDown:
method (why can't Desdemona receive an action from the NSMatrix and
do the transition itself?).
I'd love to do that! I couldn't figure out how though. Using NSMatrix
seems to be somewhat under-documented.
Is there a way to configure the NSMatrix to send a 'somebody clicked
me!' event to its delegate?
Also, you're keeping the state of the game in your NSMatrix subclass.
It's not ideal, but it's only a cache of the state used for display
purposes. The _actual_ state is somewhere else, in an instance of a
SBReversiState (hidden away in a framework[0] in vendor/AlphaBeta).
having to rework the other. Use the class Desdemona as a controller
object, to translate click actions into state changes, and to
propagate state changes to the display.
This is what I'm aiming at, yes. The alphaBeta[1] instance variable
in Desdemona contains the actual model.
[0] your book came in real handy learning how to create those ;)
Stig
--
http://code.brautaset.org
http://blog.brautaset.org
_______________________________________________
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