File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -460,11 +460,21 @@ class GameScene: SKScene, SKPhysicsContactDelegate {
460
460
461
461
// Check to see if the pipe in front has gone behind the bird
462
462
// if so, make the new pipe in front of the bird the target pipe
463
- if pipes. children [ currentPipe] . position. x < bird. position. x {
463
+ if pipes. children. count > 1 {
464
+ if pipes. children [ currentPipe] . position. x < bird. position. x {
464
465
465
- currentPipe = closestPipe ( pipes: pipes. children)
466
+ currentPipe = closestPipe ( pipes: pipes. children)
467
+ }
468
+ }
469
+
470
+ if pipes. children. count == 1 {
471
+ if pipes. children [ 0 ] . position. x < bird. position. x {
472
+
473
+ currentPipe = 0
474
+ }
466
475
}
467
476
477
+
468
478
// Distance between next pipe and bird
469
479
let distanceOfNextPipe = abs ( pipes. children [ currentPipe] . position. x - bird. position. x)
470
480
You can’t perform that action at this time.
0 commit comments