Looking for feedback on design pattern for simple 2D environment

Posted by Le Mot Juiced on Game Development See other posts from Game Development or by Le Mot Juiced
Published on 2012-08-27T17:54:12Z Indexed on 2012/08/27 21:57 UTC
Read the original article Hit count: 172

Filed under:
|
|

I'm working in iOS.

I am trying to make a very simple 2D environment where there are some basic shapes you can drag around with your finger. These shapes should interact in various ways when dropped on each other, or when single-tapped versus double-tapped, etc.

I don't know the name for the design pattern I'm thinking of. Basically, you have a bunch of arrays named after attributes, such as "double-tappable" or "draggable" or "stackable". You assign these attributes to the shapes by putting the shapes in the arrays.

So, if there's a double-tap event, the code gets the location of it, then iterates through the "double-tappable" array to see if any of its members are in that location. And so on: every interactive event causes a scan through the appropriate array or arrays.

It seems like that should work, but I'm wondering if there's a better pattern for the purpose.

© Game Development or respective owner

Related posts about 2d

Related posts about iphone