GeekGameBoard (was: Re: Touch-and-drag architecture question)

2010-02-15 Thread Dave DeLong
Thanks, Jens!  I'd never heard of this before, and it looks like it'll fit the 
bill nicely.  However, I'm a total noob when it comes to CoreAnimation, so it 
may be a while before I grok what's going on underneath.

As far as GGB goes, how well does it handle custom boards?  For example, let's 
say I wanted to recreate this board:  
http://gallery.me.com/davedelong#100084/Boardbgcolor=black (dots are valid 
positions, and lines indicate valid moves between positions).  

Presumably I'd be creating a custom Grid subclass and building the board 
layout in there.  My board is based on a square grid, but I'm not sure how I'd 
only make some of the grid positions valid locations, nor how I'd draw the 
lines in between them.  What would I need to do to recreate this board?

Thanks!

Dave

On Feb 14, 2010, at 3:18 PM, Jens Alfke wrote:

 CoreAnimation is the best way to go for board games IMO. Lighter weight than 
 views, and it does the interpolation for you.
 
 I wrote a framework for board games using CA:
 http://bitbucket.org/snej/geekgameboard
 
 --Jens   {via iPhone}
 
 
 On Feb 14, 2010, at 1:38 PM, Dave DeLong davedel...@me.com wrote:
 
 Hi everyone,
 
 I've an iPhone app that I'm working on (it's a simple game), where I've got 
 the game board on the screen, and then a row of pieces above and below the 
 board (representing the pieces controlled/captured by each player).  I'd 
 like to be able to drag pieces from these rows onto the board.  My question 
 is this:
 
 How should I set up the view hierarchy to do the drag and drop?  As I see 
 it, there are three main ways:
 
 1.  Use different views for the board and the two rows.  This is good for 
 encapsulation, but bad for cross-view dragging.
 2.  Use a single view for the board and the two rows.  This is bad for 
 encapsulation, but makes dragging much easier.
 3.  Use different views for the board and the two rows, but have an 
 invisible view on top of everything that captures all the events and passes 
 them on accordingly.  I'm not sure how this would work out.
 
 Perhaps another important question is: how should pieces be rendered?  I've 
 been drawing them with CoreGraphics (hence the difficulty of dragging them 
 between views), but I could also make each piece its own UIView (which might 
 complicate dragging in other ways).
 
 What do you suggest?
 
 Thanks!
 
 Dave DeLong
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 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:
 http://lists.apple.com/mailman/options/cocoa-dev/jens%40mooseyard.com
 
 This email sent to j...@mooseyard.com



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: GeekGameBoard (was: Re: Touch-and-drag architecture question)

2010-02-15 Thread Jens Alfke

On Feb 15, 2010, at 8:49 AM, Dave DeLong wrote:

 As far as GGB goes, how well does it handle custom boards?  For example, 
 let's say I wanted to recreate this board: 
 http://gallery.me.com/davedelong#100084/Boardbgcolor=black (dots are valid 
 positions, and lines indicate valid moves between positions).  
 Presumably I'd be creating a custom Grid subclass and building the board 
 layout in there.  My board is based on a square grid, but I'm not sure how 
 I'd only make some of the grid positions valid locations, nor how I'd draw 
 the lines in between them. What would I need to do to recreate this board?

You can create a 7x7 RectGrid and then call -removeCellAtRow:column: to remove 
the cells that don't appear in that board. You'd also want to set the 
borderWidth to 0 in the remaining cells so they don't draw their square 
outlines.

Alternatively, you could just start with an empty board and add a BitHolder 
object for every valid position.

Drawing the background lines is up to you. You could create a fancy image of 
the board and add it as a PNG file, or you could make a CALayer for the 
background that has a custom drawing callback.

—Jens___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com