Question

I am trying to detect the coordinates where two sprites (shipLaser and baddie) intersect and then make a new sprite (speedPowerUp) in that position. Below is what I have attempted to do with nodeAtPoint but it is just running and then crashing when the two sprites intersect.

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];

            }

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top