cs193p – Assignment #3 Extra Task #1

Please note, this blog entry is from a previous course. You might want to check out the current one.

Animate the removal of matched cards. UICollectionView will do this for you if you call the deleteItemsAtIndexPaths: method. Just remember that at any time you call deleteItemsAtIndexPaths:, the UICollectionView’s dataSource (your Controller on behalf of your Model) must be in the state that will exist after the deletion happens. Otherwise you will crash with an assertion in the delete (because it will delete the items and try to reset everything and the new state of the UICollectionView will not match its dataSource’s idea of things). You can animate the dealing of 3 new cards as well using insertItemsAtIndexPaths: (though that animation is just “dissolving in” the new cards … deletion is far more exciting).

The first part – animating the removal or cards – is already implemented. A simpler solution would have been just to call reloadData after the data source was adjusted …
Continue reading “cs193p – Assignment #3 Extra Task #1”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #3 Task #13 & #14

Please note, this blog entry is from a previous course. You might want to check out the current one.

The user should still be able to abandon the game and start over with a fresh group of cards at any time (i.e. re-deal).

… which actually works already … Main topic here is to do not forget to reload the data for the collection view …

The game must work properly (and look good) in both Landscape and Portrait orientations on both the iPhone 4 and the iPhone 5. Use Autolayout to make this work (not struts and springs).

… its recommend to watch lecture #8 before solving this task.
Continue reading “cs193p – Assignment #3 Task #13 & #14”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #3 Task #10 & #11

Please note, this blog entry is from a previous course. You might want to check out the current one.

If there are more cards than will fit on the screen, simply allow the user to scroll down to see the rest of the cards. Pick a fixed (and reasonable) size for your cards and keep them that size for the whole game.

… which the code already does by default …

It is very important that you continue to have a “last flip status” UI and that it show not only matches and mismatches, but also which cards are currently selected (because there can be so many cards now that you have to scroll to get to all the cards in a match). A UILabel may no longer be sufficient for this UI.

To rewrite the current status label the updateUI method has to be overwritten by the set-game view controller. Do display the card symbols in the status label, we will add a subview for each card. At the start we make sure there is no subview from a previous status display. If there are any we loop over each of them and remove it.
Continue reading “cs193p – Assignment #3 Task #10 & #11”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #3 Task #9

Please note, this blog entry is from a previous course. You might want to check out the current one.

Do something sensible when no more cards are in the deck and the user requests more.

There a various “sensible” solutions, lets just disable the button and gray it out, when there are no cards left in the deck:

- (IBAction)addCardsButtonPressed:(UIButton *)sender {
    ...
    if (self.game.deckIsEmpty) {
        sender.enabled = NO;
        sender.alpha = 0.5;
    }
}

Continue reading “cs193p – Assignment #3 Task #9”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #3 Task #8

Please note, this blog entry is from a previous course. You might want to check out the current one.

Automatically scroll to show any new cards when you add some in the Set game.

After a the data has been reloaded scroll to the last item:

- (IBAction)addCardsButtonPressed:(UIButton *)sender {
    ...    
    [self.cardCollectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:(self.game.numberOfCards - 1) inSection:0]
                                    atScrollPosition:UICollectionViewScrollPositionBottom
                                            animated:YES];
}

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #3 Task #7

Please note, this blog entry is from a previous course. You might want to check out the current one.

In the Set game (only), the user must always have the option somewhere in the UI of requesting 3 more cards to be dealt at any time if he or she is unable to locate a Set.

In storyboard drag out a new button set its tag to 3, provide a suitable name and link it to an action in the game view controller (or the set-game view controller – either works).

cs193p - assignment #3 tast #7
cs193p – assignment #3 tast #7

Continue reading “cs193p – Assignment #3 Task #7”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail