If on Edge, Bounce
If on edge, bounce
Category Motion
Type Stack

The If on Edge, Bounce block is a Motion Block and a Stack Block. The block checks to see if its sprite is touching the edge of the screen - and if it is, the sprite will point in the opposite direction.

Behind the ScenesEdit

The If on Edge, Bounce block can't be simply replicated as it changes the direction depending on whether the sprite is touching the top/bottom or left/right sides. If it touching the sides - the direction is simply multipled by -1 which causes the sprite to reflect.

If it is touching the top or bottom then the direction becomes (direction + 180) * -1

Common UsesEdit

  • Preventing a sprite from partially leaving the screen (often, this is followed by the Point in Direction block to stop reflection)
  • Reflection
  • Games such as "Pong"