-1

画面に 4 つのリンゴと 4 つのオレンジがあり、それぞれに 2 つのバスケットがあります。リンゴとオレンジをそれぞれのバスケットに正常にドラッグしています。

すべての商品がカゴに入ったことを数える方法は? : マイコード

    CGPoint location = [touch locationInView:touch.view];
    apple.center = location;

   if (apple.center.x == 233 || apple.center.y == 368)
   {
    apple.hidden = YES;
   }
4

1 に答える 1

0

と の2 つのintカウンターを使用します。numberOfApplesInBasketnumberOfOrangesInBasket

CGPoint location = [touch locationInView:touch.view];
apple.center = location;

if (apple.center.x == 233 || apple.center.y == 368)
{
  apple.hidden = YES;
  numberOfApplesInBasket += 1;
  if (numberOfApplesInBasket == 4 && numberOfOrangesInBasket == 4) {
    // Do your thing
  }
}
于 2012-12-30T11:04:14.400 に答える