【发布时间】:2011-09-03 19:41:08
【问题描述】:
到目前为止我有代码
- (void)CreatenewBlock:(int)blockCountToSpawn
{
for (int i=0; i != blockCountToSpawn; i++)
{
theBlockxCord = arc4random() % 4;
theBlockyCord = arc4random() % 4;
NSLog(@"New Block with Cords (%i, %i)",theBlockxCord, theBlockyCord);
}
}
这个循环直到它到达blockCountToSpawn的anunt 这完全符合我的要求,但我想每次都将 theBlockxCord 设置为一个新变量。所以最终结果会是这样的:
theBlockxCordOfBlock1=2
theBlockxCordOfBlock2=4
theBlockxCordOfBlock3=1
theBlockxCordOfBlock4=3
而不是每次都覆盖 BlockXCord。
对于奖励积分,是否有一种方法可以在数组中调用它们,所以我不必继续这样做:
if (theBlockxCordOfBlock1 == 2 || theBlockxCordOfBlock3 == 2 ..etc)
{
do stuff..
}
【问题讨论】:
标签: objective-c variables int