因此,我做了什麼是我的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)]];
}
}
}
}