使用 for 循环进行命中测试

发布于 2024-10-08 21:57:36 字数 467 浏览 0 评论 0原文

我有 10 块砖块,每当我的球击中其中一块时,我就想移走那块砖块。 (打砖块)

这就是我尝试过

for (int bri=1; bri<11; bri++) {
//  NSObject *brickimg = [NSObject stringWithFormat:@"brick%d", bri];
//  if (CGRectIntersectsRect(ball.frame, brickimg.frame)) {
//      [UIImageView stringWithFormat:@"brick%d", bri].hidden = YES;
//  }
}

的,

UIImageView *brickimg = [UIImageView stringWithFormat:@"brick%d", bri];

但没有机会。 正确的语法是怎样的?

i have 10 bricks, whenever my ball hit one of them i want to remove that brick. (brick breaker)

That is what i tried

for (int bri=1; bri<11; bri++) {
//  NSObject *brickimg = [NSObject stringWithFormat:@"brick%d", bri];
//  if (CGRectIntersectsRect(ball.frame, brickimg.frame)) {
//      [UIImageView stringWithFormat:@"brick%d", bri].hidden = YES;
//  }
}

and also

UIImageView *brickimg = [UIImageView stringWithFormat:@"brick%d", bri];

but no chance.
How is the correct Syntax ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妳是的陽光 2024-10-15 21:57:36

在正确的类(即 NSString)上调用 stringWithFormat: 怎么样?

How about calling stringWithFormat: on the correct class, which is NSString?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文