所以我所做的是我为我的 CCSPRITE 瓷砖随机化了锚点和旋转速度,但这破坏了我的碰撞。我如何计算对象的边界框,同时它从锚点上旋转旋转。
-(void)rotateTiles
{
int aheadcount = [asteroids count];
CCSprite *tileonPos[aheadcount];
NSValue *tilecoord1;
NSValue *spin;
//NSLog(@"%d",aheadcount);
for(int v=0; v<aheadcount; v++)
{
tilecoord1 = [self.asteroids objectAtIndex:v];
spin = [self.spinvalues objectAtIndex:v];
CGPoint spinint = [spin CGPointValue];
CGPoint cgp = [tilecoord1 CGPointValue];
tileonPos[v] = [bglayer tileAt:cgp];
tileonPos[v].rotation+=spinint.x;
tileonPos[v].anchorPoint=ccp(0,spinint.y);
}
}
-(void)findTiles
{
CGPoint tilecoord1;
int tileGid1;
for(int x = 0; x<30; x++)
{
for(int y = 0; y<20; y++)
{
tilecoord1 = ccp(x+(480*currentlevel),y);
tileGid1 = [bglayer tileGIDAt:tilecoord1];
if(tileGid1 == 1)
{
int randomanchorx = ( (arc4random() % (5+5+1)) -5 );
int randomspin = ( (arc4random() % (5+5+1)) -5 );
[self.asteroids addObject:[NSValue valueWithCGPoint:CGPointMake(x,y)]];
[self.spinvalues addObject:[NSValue valueWithCGPoint:CGPointMake(randomspin,randomanchorx)]];
}
}
}
}