我正在尝试设计一款非常简单的纸牌游戏。功能基本上在于发现卡片,只需点击它们即可。要做到这一点,我把卡放在UIView上,然后我覆盖其他UIView,我抓住了水龙头。然后我只计算了哪个卡被点击了我翻转它。
问题是,如果我点击了错误的卡片,这个水龙头似乎仍然保留在一种缓冲区中,当我点击另一张卡片时,有时前一张卡片会轻敲而不会被轻敲。这个缓冲区是真的还是我做错了什么?如果此缓冲区是真实的,那么每次捕获新点击时如何删除其内容?
提前致谢。
问题解决了:)
以下是问题所在代码的一部分 点击卡片并检查它是否为王。
[...]这里的一些代码[...]
// And if what we have found is a king, then we uncover the next card in the game stack and .
if ([[gameWindow.deck getCardAtIndex:gameWindow.lastIndex] cardValue] == 9) {
//[self uncoverTheNextCardToPlay];
do {
[self uncoverTheNextCardToPlay];
} while ([[gameWindow.deck getCardAtIndex:gameWindow.lastIndex] cardValue] == 9 && gameWindow.lastIndex < 40);
}
// And we update the realIndex with the real index index of the card just uncovered.
gameWindow.realIndex = ([[gameWindow.deck getCardAtIndex:gameWindow.lastIndex] cardSuit]*10)+[[gameWindow.deck getCardAtIndex:gameWindow.lastIndex] cardValue];
[...]此处有更多代码[...]
- (void)uncoverTheNextCardToPlay
{
gameWindow.lastIndex = gameWindow.lastIndex+10;
[[gameWindow.deck getCardAtIndex:gameWindow.lastIndex] setCover:NO];
[[gameWindow.deck getCardAtIndex:gameWindow.lastIndex] refreshCardWithCardBack:gameWindow.cardBack];
gameWindow.realIndex = ([[gameWindow.deck getCardAtIndex:gameWindow.lastIndex] cardSuit]*10)+[[gameWindow.deck getCardAtIndex:gameWindow.lastIndex] cardValue];
}