CollisionEdge Event
Previous Top Next

CollisionEdge event occurs when a sprite collides with one of the edges.
Sprite1 property holds the colliding sprite.
Edge property holds a number that represents the specific boundary.

Example:
Sub gw_CollisionEdge
'This event occurs when a sprite hits one of the boundaries.
      sprite.Value = gw.Sprite1 'Get the sprite.
      If gw.SpriteIndex(sprite.Value) = 0 Then Return 'Ignore the explode sprite.
      Select gw.Edge 'Check the edge value and set the new direction accordingly.
    Case 1 'east
      iMinAngle = 135 : iMaxAngle = 225
    Case 2 'southeast
      iMinAngle = 180 : iMaxAngle = 270
    Case 3 'south
      iMinAngle = 225 : iMaxAngle = 315
    Case 4 'southwest
      iMinAngle = 270 : iMaxAngle = 359
    Case 5 'west
      iMinAngle = 0 : iMaxAngle = 45
    Case 6 'northwest
      iMinAngle = 0 : iMaxAngle = 90
    Case 7 'north
      iMinAngle = 45 : iMaxAngle = 135
    Case 8 'northeast
      iMinAngle = 90 : iMaxAngle = 180
      End Select
      angle = Rnd(iMinAngle,iMaxAngle)
      sprite.Direction = angle 'Set the new direction.
      Sound("bounce.wav") 'Play the sound.
End Sub