を提案してくださいあなたのスプライトの配列を持ち、またはあなたがそれを行うことができbatchNodeを使用している場合。
衝突が発生したら、スプライトを通過します。彼らの位置と爆発センターとの距離を確認し、範囲内にある場合はそれらを殺す。
CCSprite *sprite;
for (sprite in [batchNode descendants]) {
if ([sprite isInRangeOf:[explosionSprite position]]) {
[sprite yourRemovalMethod];
}
}
方法 'isInRangeOf:' ..
何かのようなあなたのスプライトサブクラス内役立ちます
-(BOOL) isInRangeOf:(CGPoint)explosionCenter {
//Use pythagoras theorem to work out the distance between [sprite position] and [explosionCenter]
CGFloat dx = explosionCenter.x - [self position].x;
CGFloat dy = explosionCenter.y - [self position].y;
float distance = sqrt(dx*dx + dy*dy);
// If your distance is less than or equal to your 'death radius' return YES, else No.
if (distance <= 25) {
return TRUE;
} else {
return FALSE;
}
}
希望でしょう。
私の答えはあなたの問題を解決しましたか? – Bongeh