Sprite Lab Documentation

 bounces off 
Category:Actions

If the first sprite is touching the second sprite, then the first sprite moves away from the second sprite in the opposite direction it was originally moving.

Examples

Example 1

Sprites that are wandering can bounce off of each other.

Example 2

Sprites that are moving left and right using the swimming left and right block can bounce off of a middle obstacle.

Syntax

bounceOff

Parameters

NameTypeRequired?Description
sprite 1

The sprite that will bounce off sprite 2

sprite 2

The sprite that causes sprite 1 to bounce

Tips

  • This block works best under the sprite touches sprite event for sprites with behaviors that use the move forward block such as “wandering” or “swimming left and right”.
  • If a sprite is programmed with move in direction blocks, this block does not change the selected direction.

Found a bug in the documentation? Let us know at support@code.org.