From 5fb3da5a77c7644ceb2fc68eb1ebac2728c33485 Mon Sep 17 00:00:00 2001 From: Ron Hale-Evans Date: Thu, 14 Jul 2016 12:47:33 -0700 Subject: [PATCH] New Game topic --- docs/reference/game/if-on-edge-bounce.md | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 docs/reference/game/if-on-edge-bounce.md diff --git a/docs/reference/game/if-on-edge-bounce.md b/docs/reference/game/if-on-edge-bounce.md new file mode 100644 index 00000000..7091679f --- /dev/null +++ b/docs/reference/game/if-on-edge-bounce.md @@ -0,0 +1,34 @@ +# If On Edge, Bounce + +Make a [sprite](/reference/game/create-sprite) on the edge of the +[LED screen](/device/screen) bounce away. + +```sig +let item = game.createSprite(0, 2); +item.ifOnEdgeBounce(); +``` + +### Parameters + +* a **sprite** that might be on the edge of the LED screen. + +### Example + +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)); +}); +``` + +### See also + +[create sprite](/reference/game/create-sprite), +[touching](/reference/game/touching), +[touching edge](/reference/game/touching-edge)