0

I'm developing a Flappy Bird clone (for learning purposes only!), but am a little confused when trying to detect when the bird has been pushed off-screen.

My plan was something akin to

if bird.position.x < 0 {
    // Bird is off screen, game over
}

However, this doesn't work as the bird (when hitting the left edge of the frame) seems to have a position.x of about (but not exactly) 270.

Am I going about this the wrong way?

rickster
  • 124,678
  • 26
  • 272
  • 326
user1381745
  • 3,850
  • 2
  • 21
  • 35
  • @0x141E this sorts out the boundaries correctly - thank you - but seems to screw up the sprite positioning. With an X co-ord of 358, the bird is almost touching the right hand edge. How should I adjust the position settings with .ResizeFill set? – user1381745 Dec 02 '14 at 20:04
  • Doesn't position.x and position.y refer to the center of the sprite in SpriteKit by default (assuming you didn't change the anchor center) ? So maybe you need `bird.position.x + (bird.size.width / 2.0)` to ensure the entire bird node is really off screen ? – Zhang Dec 03 '14 at 02:30

0 Answers0