0

I'm writing a card game for iOS/AppleTV, I have all the cards and other logics pretty much there. But I am stuck when it comes to displaying cards on the screen.

The cards need to be lined up one after the other; so I figure a collection view is the best way to do this; its horizontal; it sorts out the distance and you can use autolayout to position it correctly.

But I am not sure about the following

  1. I want a deck of cards on the screen, which is not part of the collectionView.

  2. I want to animate cards, one at a time going from the deck to each slot of the collectionView (lets say it has 6 slots) the cards will be face down.

  3. Once this is done, the cards will then animate from left to right to flip them face up.

I am wondering if its possible to animate something outside of the collection view into a collection view -- or even if a collection view is the best way to display, render and handle a row of cards?

Many thanks

zardon
  • 1,601
  • 4
  • 23
  • 46
  • That is not something commonly done so don't expect a complete and good sample code, but that is definitely possible to do. The only possible issue caused by a use of a collection view is that it might not provide you enough information about out-of-screen content, especially if the sizes are or should be really dynamic. – A-Live Jan 05 '16 at 12:04
  • I wasn't after sample code, I just wasn't sure if I could move one item outside of its ui component into it -- the images/sizes won't be that dynamic; and if necessary a scroll component will be added. – zardon Jan 05 '16 at 13:15
  • This part will certainly require trickery with dummy cells and accurate substitution. You don't have to move a view to the collection view - making it look like that is all the user needs - but if that is what you really want there's no big deal at moving a view to some other superview. – A-Live Jan 05 '16 at 13:40
  • But whats the alternative? Draw cards to specific points on the screen? Into a "tableau" which has a fixed X, Y and spacing, etc? – zardon Jan 06 '16 at 11:11
  • I think it will be easier to start with linear movements, it will only require to set the new frames hooked to standard UIVIew animation calls. Making beautiful arcs and minor rotation or even a flip while the card is moving would be awesome, but that will require a more advanced solution, perhaps calculation of the desired trajectories, velocity and such, all used at some kind of a loop. – A-Live Jan 06 '16 at 12:24

0 Answers0