Scratch for Java

Sprite::ifOnEdgeBounce()

Checks if the sprite is on the edge of the stage and bounces it back if it is. The sprite's direction is reversed when it hits the left or right border, and it is reversed and rotated by 180 degrees when it hits the top or bottom border. The method does nothing if the hitbox is disabled or if the sprite is a UI element. It also does nothing if the sprite has not been added to a stage yet.

Examples

View on GitHub

Syntax

Java

.ifOnEdgeBounce()

Scratch

if on edge, bounce

Return

void

ifOnEdgeBounce()

Create Shareable URL

Select Sections