spritekit nodeAtPoint的交集

时间:2014-02-20 04:20:12

标签: hidden intersect coordinate

我正在尝试检测两个精灵(shipLaser和baddie)相交的坐标,然后在该位置创建一个新的精灵(speedPowerUp)。以下是我尝试对nodeAtPoint进行的操作,但它正在运行,然后在两个精灵相交时崩溃。

for (SKSpriteNode *baddie in _baddies)
{

    baddie.name = @"baddie1";

    if (baddie.hidden) {
        continue;
    }
    for (SKSpriteNode *shipLaser in _shipLasers){
        if (shipLaser.hidden) {
            continue;
        }

        if ([shipLaser intersectsNode:baddie]) {
            shipLaser.hidden = YES;
            baddie.hidden = YES;
            [shipLaser nodeAtPoint:*(_itemDrop)];
            NSLog(@"You just destroyed a baddie");
            _score = _score + 10;
            _scoreLabel.text = [NSString stringWithFormat:@"%i", _score];
            if (_score == 10)
            {

                _speedPowerUp.hidden = NO;
                _speedPowerUp.position = *(_itemDrop);
                [self addChild:_speedPowerUp];

            }

0 个答案:

没有答案