Hide DAL.x behind Enum

This commit is contained in:
Amerlander
2020-02-20 17:00:11 +01:00
parent 004b1d9662
commit 07fe2645cf
56 changed files with 101 additions and 101 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.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
input.input.onButtonEvent(Button.A, ButtonEvent.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.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
if (Math.randomBoolean()) {
} else {
}
@ -34,7 +34,7 @@ input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
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.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
input.input.onButtonEvent(Button.A, ButtonEvent.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.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
basic.showIcon(IconNames.Diamond)
basic.showIcon(IconNames.SmallDiamond)
basic.showIcon(IconNames.Diamond)

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.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
input.input.onButtonEvent(Button.A, ButtonEvent.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.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
input.input.onButtonEvent(Button.A, ButtonEvent.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.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
});
```
@ -21,7 +21,7 @@ input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
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.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
basic.showLeds(`
# # . # #
# # . # #
@ -37,7 +37,7 @@ input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
Add ``||input:on button pressed||`` and ``||basic:show leds||`` blocks to display a frowny when button **B** is pressed.
```blocks
input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
basic.showLeds(`
# # . # #
# # . # #
@ -53,7 +53,7 @@ input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
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.input.onButtonEvent(Button.AB, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
input.input.onButtonEvent(Button.AB, ButtonEvent.Click, () => {
basic.showLeds(`
. . . . .
# . # . .