EveryGame iPad Blog

Monday, August 16, 2010

Free Piece Movement in EveryGame

Recently, we've gotten a couple of questions regarding creating games by loading on pieces, without needing to create individual board spaces for them, so I thought I would share one of my responses with everyone.

Right now, you do have to define locations for the pieces to live it. The underlying engine is created in such a way that one giant location, where you drag pieces around to an arbitrary location inside of it would be possible. However, there's lots of extra code and debugging needed to actually implement such a thing. I think it could happen in the future, but it won't be available in the next few releases.

However, there are tricks to get close to that. With the "rows" and "cols" specifiers in the location tab, you could easily make an entire grid that covers the entire background. Just make the cells 20x20 or so perhaps, and start them at coord (0,0). Pieces can actually be much larger than the location that holds them, and now you could drag them around the iPad, and while they'll rigidly snap, it'd only be a small distance to the nearest cell.

The only difficulty is that you actually have to tap in the location to select a piece to tap / move. This means that if your locations are too small, it can be hard to pick them. So the smaller the location, the closer approximation to free movement, but the more difficult it is to grab pieces. One clever trick I saw was to put a dot, or other "handle" in the center of the image for each piece. Since the center of the piece will correspond with the location (where you have to tap), it makes it much more evident where you grab the piece from, and lets you easily work with pieces much larger than their grid squares.

Hopefully that gives some of you an idea of how you could set up free pieces movement in your own games. I'm out and about typing this entry from my iPad now, but I'll try and upload a simple game that demonstrates this technique to the Google Group soon.

No comments:

Post a Comment