cs193p – Assignment #4 Task #10

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

Use a UIDynamicAnimator to allow the cards in either game to be gathered up into a pile via a pinch gesture. Once gathered, the stack of gathered cards must be able to be moved around (via a pan gesture). Tapping on the stack will return the cards to their normal positions (animated, of course) unharmed.


Start by adding a pan and a pinch to the grid views of both game view controllers in storyboard and link them to actions in the generic game-view-controller class.

Add a new property to the game-view-controller class, which will store the current animations:

@property (strong, nonatomic) UIDynamicAnimator *pileAnimator;

Continue reading “cs193p – Assignment #4 Task #10”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #4 Task #9

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

The movement of the elements inside your UI that occur in response to device rotation must be animated (Autolayout already animates any changes it makes for you, but any other layout changes that you do in code must be animated by you).

… actually already handled by the previous task.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #4 Task #8

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

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 as much as possible to make this work. Positioning the cards themselves will require some additional work (although you are probably already doing this work for some of the Required Tasks above). None of your code should be specific to any given screen width or height or orientation (i.e. no “if landscape then” or “if width/height … then” code). The bottom line of this task is that your MVCs’ Views should look good in any reasonably-sized bounds rectangle.

Go to storyboard make sure, all views in all controllers are where they should be (aligned with blue lines etc…), and add constraints using “reset to suggested constraints”:

cs193p – assignment #4 task #8 – set suggested constraints
cs193p – assignment #4 task #8 – set suggested constraints

Continue reading “cs193p – Assignment #4 Task #8”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #4 Task #7

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

Animate re-deals.

The adding new cards part has already been handled by the previous task. Just animate the removal of the old cards by moving them to the bottom left corner:

- (IBAction)touchDealButton:(UIButton *)sender {
    ...
    for (UIView *subView in self.cardViews) {
        [UIView animateWithDuration:0.5
                         animations:^{
                             subView.frame = CGRectMake(0.0,
                                                        self.gridView.bounds.size.height,
                                                        self.grid.cellSize.width,
                                                        self.grid.cellSize.height);
                         } completion:^(BOOL finished) {
                             [subView removeFromSuperview];
                         }];
    }
    ...
}

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #4 Task #6

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

The arrival and departure of cards must be animated and, as they come and go, you must automatically adjust the layout of the cards in your user-interface (i.e. their size and position) to efficiently use the real estate on screen (i.e. don’t waste space) and make them all fit.

… a minor bug was introduced in task #3 … the code was added to the super class, thus also playing cards get removed which makes the game really difficult. Lets add a new public property to choose if card should be removed or stay:

@property (nonatomic) BOOL removeMatchingCards;

Continue reading “cs193p – Assignment #4 Task #6”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #4 Task #5

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

Use a flip transition to animate choosing cards in the Playing Card game (so that the cards look like they are being flipped over when chosen).

When choosing a card, set that card to its new “future” state for the animation. When the animation is complete reset that change and run the “original” code of updating the game and the user interface:
Continue reading “cs193p – Assignment #4 Task #5”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #4 Task #4

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

As in a real game of Set, the user should start with 12 cards and then have the option of requesting 3 more cards to be dealt at any time if he or she is unable to locate a Set. Do something sensible when there are no more cards in the deck.

Add a new button in storyboard and set its tag to 3 (the number of cards that should be added):

cs193p – assignment #4 task #4 – add cards button
cs193p – assignment #4 task #4 – add cards button

Continue reading “cs193p – Assignment #4 Task #4”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail