2016-07-14 21:47:33 +02:00
|
|
|
# If On Edge, Bounce
|
|
|
|
|
|
|
|
Make a [sprite](/reference/game/create-sprite) on the edge of the
|
|
|
|
[LED screen](/device/screen) bounce away.
|
|
|
|
|
|
|
|
```sig
|
2019-12-02 05:58:26 +01:00
|
|
|
game.createSprite(0, 2).ifOnEdgeBounce();
|
2016-07-14 21:47:33 +02:00
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Parameters
|
2016-07-14 21:47:33 +02:00
|
|
|
|
|
|
|
* a **sprite** that might be on the edge of the LED screen.
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Example
|
2016-07-14 21:47:33 +02:00
|
|
|
|
|
|
|
This program makes a sprite on the right edge of the screen with a
|
|
|
|
direction of 90 degrees, and bounces it so it has a direction of -90
|
|
|
|
degrees -- exactly the opposite direction.
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
let ball = game.createSprite(4, 2);
|
|
|
|
basic.showNumber(ball.get(LedSpriteProperty.Direction));
|
|
|
|
input.onButtonPressed(Button.B, () => {
|
|
|
|
ball.ifOnEdgeBounce();
|
|
|
|
basic.showNumber(ball.get(LedSpriteProperty.Direction));
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## See also
|
2016-07-14 21:47:33 +02:00
|
|
|
|
|
|
|
[create sprite](/reference/game/create-sprite),
|
2019-12-02 05:58:26 +01:00
|
|
|
[is touching](/reference/game/is-touching),
|
|
|
|
[is touching edge](/reference/game/is-touching-edge)
|