The function checks to see if its sprite is touching the edge of the screen with the move steps block — and if it is, the sprite will point in a direction that mirrors the direction from which it is coming. It uses a line perpendicular to the edge to determine the reflection angle.
The example demonstrates the wall bouncing of the sprite, rotation style, and costume change in Python.
Code
sprite = Sprite('Tobi')
import time
sprite.setrotationstyle('left-right')
while True:
sprite.move(5)
sprite.bounceonedge()
sprite.switchcostume("Tobi walking 1")
time.sleep(0.1)
sprite.move(5)
sprite.bounceonedge()
sprite.switchcostume("Tobi walking 2")
time.sleep(0.1)
Output
Read More