Please note, this blog entry is from a previous course. You might want to check out the current one.
When a Set match is successfully chosen, the matching cards should now be removed from the game (not just blanked out or grayed out, but removed from the UI entirely).
When looping of the cards check if it matches, if it does remove it from the super view and form the view array. Before creating a new view check, if the cared has already matched earlier, to avoid recreating its view:
- (void)updateUI { ... if (viewIndex == NSNotFound) { if (!card.matched) { ... } } else { cardView = self.cardViews[viewIndex]; if (!card.matched) { [self updateView:cardView forCard:card]; } else { [cardView removeFromSuperview]; [self.cardViews removeObject:cardView]; } } ... }
The complete code is available on github.
I am wondering when the view redraws everything just after two cards are matched?
– (void)updateView:(UIView *)view forCard:(Card *)card
method would not be triggered after two cards are matched, I think.
When a card is matched and removed, I remove the card from the super view. Why should I want to redraw the card when I do that? Concerning the other cards, they are redrawn, when changing their size.
Why should I want to redraw the card when I do that?
ah, you don’t need to. I was wondering when runtime remove these two matched card. because [cardView removeFromSuperview]; will not remove the card immediately from our sight.
I mean it remove these two cards after the updateUI method finished.
Only Set cards should disappear from the view according to the task, the playing cards not. So this code should be placed in the updateView of the SetCardGameViewController right? Along with moving the “view.alpha = card.matched ? 0.6 : 1.0;” to the PlayingCardGameViewController?
The “graying out” part was introduced in the previous task as intermediary for the set game. For the playing-cards game we always removed the card. Do I remember wrongly?
Ah, allright, I’m don’t remember either and don’t care enough to check, doesn’t matter!