update input blocks in docs and tests

This commit is contained in:
Amerlander
2020-02-20 04:01:37 +01:00
parent 38cf0ec0c6
commit c2cdcaa40f
62 changed files with 109 additions and 115 deletions

View File

@ -11,7 +11,7 @@ Let's create a coin flipping program to simulate a real coin toss. We'll use ico
Get an ``||input:on button A pressed||`` block from the ``||input:Input||`` drawer in the toolbox. We'll put our coin flipping code in here.
```blocks
input.onButtonPressed(Button.A, () => {
input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
})
```
@ -22,7 +22,7 @@ Grab an ``||logic:if else||`` block and set it inside ``||input:on button A pres
The ``||Math:pick random true or false||`` returns a random ``true`` or ``false`` value which we use to determine a ``heads`` or ``tails`` result for a coin toss.
```blocks
input.onButtonPressed(Button.A, () => {
input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
if (Math.randomBoolean()) {
} else {
}
@ -34,7 +34,7 @@ input.onButtonPressed(Button.A, () => {
Now, put a ``||basic:show icon||`` block inside both the ``||logic:if||`` and the ``||logic:else||``. Pick images to mean ``heads`` and ``tails``.
```blocks
input.onButtonPressed(Button.A, () => {
input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
if (Math.randomBoolean()) {
basic.showIcon(IconNames.Skull)
} else {
@ -52,7 +52,7 @@ Press button **A** in the simulator to try the coin toss code.
You can animate the coin toss to add the feeling of suspense. Place different ``||basic:show icon||`` blocks before the ``||logic:if||`` to show that the coin is flipping.
```blocks
input.onButtonPressed(Button.A, () => {
input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
basic.showIcon(IconNames.Diamond)
basic.showIcon(IconNames.SmallDiamond)
basic.showIcon(IconNames.Diamond)

View File

@ -12,7 +12,7 @@ Tell everyone who you are. Show you name on the LEDs.
Let's build a **LOVE METER** machine. Place an ``||input:on pin pressed||`` block to run code when pin **0** is pressed. Use ``P0`` from the list of pin inputs.
```blocks
input.onPinPressed(TouchPin.P0, () => {
input.onPinEvent(TouchPin.P0, Button.Click, () => {
});
```
@ -21,7 +21,7 @@ input.onPinPressed(TouchPin.P0, () => {
Using ``||basic:show number||`` and ``||Math:pick random||`` blocks, show a random number from `0` to `100` when pin **0** is pressed.
```blocks
input.onPinPressed(TouchPin.P0, () => {
input.onPinEvent(TouchPin.P0, Button.Click, () => {
basic.showNumber(Math.randomRange(0, 100));
});
```
@ -35,7 +35,7 @@ Show ``"LOVE METER"`` on the screen when the @boardname@ starts.
```blocks
basic.showString("LOVE METER");
input.onPinPressed(TouchPin.P0, () => {
input.onPinEvent(TouchPin.P0, Button.Click, () => {
basic.showNumber(Math.randomRange(0, 100));
});
```

View File

@ -12,7 +12,7 @@ Use ``||input:on button pressed||`` to send a text message over radio with ``||r
Every @boardname@ nearby will receive this message.
```blocks
input.onButtonPressed(Button.A, () => {
input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
radio.sendString("Yo");
});
```
@ -41,7 +41,7 @@ radio.onReceivedString(function (receivedString) {
Press button **A** on the simulator, you will notice that a second @boardname@ appears (if your screen is too small, the simulator might decide not to show it). Try pressing **A** again and notice that the "Yo" message gets displayed on the other @boardname@.
```blocks
input.onButtonPressed(Button.A, () => {
input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
radio.sendString("Yo");
});
radio.onReceivedString(function (receivedString) {

View File

@ -12,7 +12,7 @@ Code the buttons on the @boardname@ to show that it's happy or sad.
Place a ``||input:on button pressed||`` block to run code when button **A** is pressed.
```blocks
input.onButtonPressed(Button.A, () => {
input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
});
```
@ -21,7 +21,7 @@ input.onButtonPressed(Button.A, () => {
Place a ``||basic:show leds||`` block inside ``||input:on button pressed||`` to display a smiley on the screen. Press the **A** button in the simulator to see the smiley.
```blocks
input.onButtonPressed(Button.A, () => {
input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
basic.showLeds(`
# # . # #
# # . # #
@ -37,7 +37,7 @@ input.onButtonPressed(Button.A, () => {
Add ``||input:on button pressed||`` and ``||basic:show leds||`` blocks to display a frowny when button **B** is pressed.
```blocks
input.onButtonPressed(Button.B, () => {
input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
basic.showLeds(`
# # . # #
# # . # #
@ -53,7 +53,7 @@ input.onButtonPressed(Button.B, () => {
Add a secret mode that happens when **A** and **B** are pressed together. For this case, add multiple ``||basic:show leds||`` blocks to create an animation.
```blocks
input.onButtonPressed(Button.AB, () => {
input.input.onButtonEvent(Button.AB, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
basic.showLeds(`
. . . . .
# . # . .

View File

@ -55,7 +55,7 @@ Use a ``||input:on button pressed||`` block to handle the **A** button. Put in a
```blocks
let sprite: game.LedSprite = null
input.onButtonPressed(Button.A, function () {
input.input.onButtonEvent(Button.A, ButtonEvent.Click, function () {
if (sprite.get(LedSpriteProperty.X) == 2) {
} else {
}
@ -74,7 +74,7 @@ Finally, pull out an ``||game:add score||`` and a ``||game:game over||`` block t
```blocks
let sprite: game.LedSprite = null
input.onButtonPressed(Button.A, function () {
input.input.onButtonEvent(Button.A, ButtonEvent.Click, function () {
if (sprite.get(LedSpriteProperty.X) == 2) {
game.addScore(1)
} else {