pxt-calliope/docs/reference/js/lessons/screen-up-and-down/challenges.md

65 lines
1.1 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# screen up and down challenges
The on screen up function. #onscreenup #docs
**Challenge 0**
Congratulations! You have completed the [Screen Up/Down tutorial](/microbit/hqjwkb) . You should have an image of a heart created and shown when the screen is moved up.
```
input.onScreenUp(() => {
images.createImage(`
# # . # #
# # # # #
# # # # #
. # # # .
. . # . .
`).showImage(0)
})
```
**Challenge 1**
Now have the Micro:bit do something when the screen is moved downward. You can do this by calling the on screen down method. Do not do anything when you call the on screen down method.
```
input.onScreenUp(() => {
images.createImage(`
# # . # #
# # # # #
# # # # #
. # # # .
. . # . .
`).showImage(0)
})
input.onScreenDown(() => {
})
```
**Challenge 2**
When the Micro:bit is moved downward, create and show an image of an upside down heart.
```
input.onScreenUp(() => {
images.createImage(`
# # . # #
# # # # #
# # # # #
. # # # .
. . # . .
`).showImage(0)
})
input.onScreenDown(() => {
images.createImage(`
. . # . .
. # # # .
# # # # #
# # # # #
# # . # #
`).showImage(0) // ***
})
```