Please note, this blog entry is from a previous course. You might want to check out the current one.
Think of some other way(s) to use animation in your application and implement it.
What happens if you shake your iPhone? The card go crazy:
- (BOOL)canBecomeFirstResponder { return YES; } - (void)viewDidAppear:(BOOL)animated { [self becomeFirstResponder]; } - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (motion == UIEventSubtypeMotionShake) { if (!self.pileAnimator) { self.pileAnimator = [[UIDynamicAnimator alloc] initWithReferenceView:self.gridView]; UIGravityBehavior *gravity = [[UIGravityBehavior alloc] initWithItems:self.cardViews]; [self.pileAnimator addBehavior:gravity]; UICollisionBehavior *collision = [[UICollisionBehavior alloc] initWithItems:self.cardViews]; collision.translatesReferenceBoundsIntoBoundary = YES; [self.pileAnimator addBehavior:collision]; UIDynamicItemBehavior *item = [[UIDynamicItemBehavior alloc] initWithItems:self.cardViews]; item.elasticity = 1.1; [self.pileAnimator addBehavior:item]; } else { self.pileAnimator = nil; [self updateUI]; } } }
… if you shake again, the return to their assigned places, but the might still be crazy (just throw them away and deal a new deck):
The complete code is available on github.
Is there a way that I can access to the description of the HWs themselves? rather than the code?
Could you please be more specific?
You can find the complete homework assignments on iTunes together with lectures and slides. You can find a copy of the individual tasks at the beginning of each respective blog entry here. A description of what the code is intended to do is interspersed between the code snippets in the blog entries as well …
Funny animator, they sure go crazy 🙂