Collision of a sprite with an edge is resolved by the sprite bouncing off the edge, either at a random or a physical/realistic angle. Once the motion is stopped, the sprite is centered.
00:58 How to code a sprite’s bouncing off an edge
01:10 Canvas edge indexing
02:05 Defining angles
05:05 Adding a counter and the sprite’s stopping and centering
09:02 Initial sprite fling/swipe
10:22 Demonstrate the sprite random bouncing
10:58 Demonstrate the sprite rigid bouncing