> On Jul 24, 2016, at 07:00, Roland King <[email protected]> wrote:
> 
> 
>> On 24 Jul 2016, at 18:42, Alex Hall <[email protected]> wrote:
>> 
>> I'm making a game based on a board. Every square on the board will be a 
>> UIButton so users can tap it. I know the size of the board (2x6) but in 
>> similar projects I may not--that is, the board size may be set by a user 
>> preference. In either case, I don't look forward to making a bunch of 
>> individual IBOutlets, and wonder if there might be a better way. Plus, with 
>> an arbitrarily-sized board, I couldn't make and wire up the outlets.
>> 
>> In such a situation, how would I do this? I'll need each button to respond 
>> to a single tap, tap and hold, and double tap. 
> 
> I wouldn’t use UIButtons at all for this. I’ll start by assuming you’re 
> talking about one tap at a time, ie that you don’t need to be able to tap 
> more than one cell simultaneously.
Correct.


> You finish one gesture then start another. 
> 
> So make your board a UIView, the whole thing, one view, and attach one 
> single, one double and one long press gesture recogniser to it, and configure 
> them appropriately so they allow each other to run or not, depending on how 
> your game works. 
> 
> Then all you have to do when you have a gesture which is recognised is to 
> take the coordinates of the gesture, and work out which virtual ‘cell’ that 
> represents on your board.  This is totally scalable from 1x1 cells to however 
> many x however many, the board dimensions are just a property of your custom 
> view. You can easily draw your own highlight as the cell is tapped and make 
> it look like a button, or probably better look not like a button but like a 
> cell in your game being tapped. 

That sounds like a really good idea. Here's the only problem: VoiceOver 
support. If I have no physical objects, how could VO users navigate the board? 
My first thought is to simulate everything, by using a directInput view and 
then adding gesture recognizers for all the VO gestures I want to support. 
Actually, this method has a couple of advantages, like supporting swiping up or 
down to move by row, whereas normal UIButtons would have the user swiping 
left/right a ton of times. But is there another way I'm missing? The more I 
think about this, the more I like it! As you said, scalable, far easier to 
manage, and cleaner.
> 
> Just make sure your cell to coordinates and coordinates back to cell logic is 
> in one place so the drawing and gameplay are using the same transformation as 
> the gesture recognisers.
This'll take some research on my part, but I think I can get it working. Thanks 
for the suggestion!

--
Have a great day,
Alex Hall
[email protected]




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to