batch replace onButtonPressed(Button...
This commit is contained in:
@ -22,7 +22,7 @@ The code under ``on button pressed("A")`` will run each time the user presses A.
|
||||
|
||||
```
|
||||
let count_ = 0
|
||||
input.onButtonPressed("A", () => {
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
count = count + 1
|
||||
})
|
||||
```
|
||||
@ -31,7 +31,7 @@ Since the count has changed, it's time to refresh the screen display. Let's add
|
||||
|
||||
```
|
||||
let count_1 = 0
|
||||
input.onButtonPressed("A", () => {
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
count = count + 1
|
||||
basic.showNumber(count, 150)
|
||||
})
|
||||
|
@ -8,7 +8,7 @@ Complete the following [guided tutorial](/microbit/lessons/counter/activity) At
|
||||
|
||||
```
|
||||
let count = 0
|
||||
input.onButtonPressed("A", () => {
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
count = count + 1
|
||||
basic.showNumber(count, 150)
|
||||
})
|
||||
@ -22,11 +22,11 @@ Let's add the code to `count` when `B` is pressed. Add an event handler with `in
|
||||
|
||||
```
|
||||
let count1 = 0
|
||||
input.onButtonPressed("A", () => {
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
count1 = count1 + 1
|
||||
basic.showNumber(count1, 150)
|
||||
})
|
||||
input.onButtonPressed("B", () => {
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
count1 = count1 - 1 // ***
|
||||
basic.showNumber(count1, 150) // ***
|
||||
}) // ***
|
||||
|
Reference in New Issue
Block a user