hiding the was pressed block (#401)
This commit is contained in:
@ -22,7 +22,7 @@ Play some motor sounds if touch sensor `1` is pressed at the same moment when an
|
||||
|
||||
```blocks
|
||||
while (true) {
|
||||
if (sensors.touch1.wasPressed() &&
|
||||
if (sensors.touch1.isPressed() &&
|
||||
sensors.ultrasonic4.distance() < 10) {
|
||||
music.playSoundEffectUntilDone(sounds.mechanicalMotorStart)
|
||||
music.playSoundEffectUntilDone(sounds.mechanicalMotorIdle);
|
||||
@ -38,8 +38,8 @@ Play some motor sounds if touch sensor `1` is pressed when both the `enter` butt
|
||||
```blocks
|
||||
while (true) {
|
||||
if (sensors.ultrasonic4.distance() < 10 &&
|
||||
sensors.touch1.wasPressed() &&
|
||||
brick.buttonEnter.wasPressed()) {
|
||||
sensors.touch1.isPressed() &&
|
||||
brick.buttonEnter.isPressed()) {
|
||||
music.playSoundEffectUntilDone(sounds.mechanicalMotorStart)
|
||||
music.playSoundEffectUntilDone(sounds.mechanicalMotorIdle);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ v = sensors.color3.light(LightIntensityMode.Reflected)
|
||||
min = v
|
||||
max = v
|
||||
setpoint = v
|
||||
while (!(brick.buttonEnter.wasPressed())) {
|
||||
while (!(brick.buttonEnter.isPressed())) {
|
||||
brick.clearScreen()
|
||||
brick.showString("Move robot on terrain", 1)
|
||||
brick.showString("Press ENTER when done", 2)
|
||||
|
@ -20,8 +20,8 @@ brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
|
||||
});
|
||||
brick.buttonEnter.pauseUntil(ButtonEvent.Bumped);
|
||||
brick.buttonEnter.isPressed()
|
||||
brick.buttonEnter.wasPressed()
|
||||
brick.setStatusLight(StatusLight.Red);
|
||||
brick.buttonEnter.wasPressed()
|
||||
```
|
||||
|
||||
## Other
|
||||
|
@ -14,7 +14,7 @@ The fact that a button was pressed earlier is remembered. Once **was pressed** i
|
||||
|
||||
Your @boardname@ has touch sensors that work like buttons. Instead of saying `enter` or `left` as the source button, use a touch sensor block with a sensor name like `touch 1`.
|
||||
|
||||
```block
|
||||
```typescript
|
||||
if (sensors.touch1.wasPressed()) {
|
||||
console.log("Hey, I was pressed.");
|
||||
}
|
||||
@ -32,7 +32,7 @@ Read about [touch sensors](/reference/sensors/touch-sensor) and using them as to
|
||||
|
||||
Set the brick light to green if the `right` button was pressed before the `left` button. If not, the brick light is turned off when the `left` button is pressed.
|
||||
|
||||
```blocks
|
||||
```typescript
|
||||
brick.buttonLeft.onEvent(ButtonEvent.Bumped, function() {
|
||||
if (brick.buttonRight.wasPressed()) {
|
||||
brick.setStatusLight(StatusLight.Green)
|
||||
@ -45,6 +45,5 @@ brick.buttonLeft.onEvent(ButtonEvent.Bumped, function() {
|
||||
## See also
|
||||
|
||||
[is pressed](/reference/brick/button/is-pressed),
|
||||
[on event](/reference/brick/button/on-event)
|
||||
|
||||
[on event](/reference/brick/button/on-event),
|
||||
[Touch sensors](/reference/sensors/touch-sensor)
|
@ -17,8 +17,8 @@ sensors.color(ColorSensorColor.Blue)
|
||||
```cards
|
||||
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {})
|
||||
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
|
||||
sensors.touch1.wasPressed()
|
||||
sensors.touch1.isPressed()
|
||||
sensors.touch1.wasPressed()
|
||||
```
|
||||
|
||||
## Gyro
|
||||
|
Reference in New Issue
Block a user