我正在运行以下代码,CCLOG 总是被触发..这两个指针具有相同的地址,我不明白为什么..我需要帮助 :)
bullets 是一个 NSMutable 数组,其中包含 20000 个 Bullet:CCSprite 实例,已在本问题末尾初始化*。
for (int i=0; i<capacity; i++)
{
Bullet* bullet = [bullets objectAtIndex:i];
if (bullet.visible )
{
for(int j=i+1;j<capacity;j++)
{
Bullet * otherBullet = bullet = [bullets objectAtIndex:j];
if(bullet.bulletId == otherBullet.bulletId)
{
CCLOG(@"noooo.. i:%i j_%j", i, j);
}
*数组初始化:
capacity=200;
bullets = [[NSMutableArray alloc] initWithCapacity:capacity];
// Create a number of bullets up front and re-use them whenever necessary.
for (int i = 0; i < capacity; i++)
{
Bullet* bullet = [Bullet bulletWithScreenRect:screenRect];
bullet.visible = NO;
bullet.bulletId=i;
[bullets addObject:bullet];
[self addChild:bullet];