Rewrote in simple language. Added blocks example.
This commit is contained in:
parent
491ff29e40
commit
74b6d99ab1
@ -1,6 +1,7 @@
|
|||||||
# Create Image
|
# Create Image
|
||||||
|
|
||||||
Create an [Image](/reference/images/image) to show on the [LED screen](/device/screen).
|
Make an [image](/reference/images/image) (picture) for the micro:bit
|
||||||
|
[LED screen](/device/screen).
|
||||||
|
|
||||||
```sig
|
```sig
|
||||||
images.createImage(`
|
images.createImage(`
|
||||||
@ -12,24 +13,34 @@ images.createImage(`
|
|||||||
`)
|
`)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Example: rock, paper, scissors
|
### Example: Flip-flopping arrow
|
||||||
|
|
||||||
The following example shows one of three images (rock, paper, or scissors) when you shake the micro:bit:
|
If you press button `A`, this program will make a picture of an
|
||||||
|
arrow and show it on the LED screen. If you press button `B`, the
|
||||||
|
program will show a picture of the button upside-down.
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
input.onGesture(Gesture.Shake, () => {
|
input.onButtonPressed(Button.A, () => {
|
||||||
let rockpaper = images.createImage(`
|
images.createImage(`
|
||||||
. . . . . # # # # # . . . . #
|
. . # . .
|
||||||
. # # # . # . . . # # # . # .
|
. # # # .
|
||||||
. # # # . # . . . # . # # . .
|
# . # . #
|
||||||
. # # # . # . . . # # # . # .
|
. . # . .
|
||||||
. . . . . # # # # # . . . . #
|
. . # . .
|
||||||
`)
|
`).showImage(0);
|
||||||
rockpaper.showFrame(Math.random(3))
|
});
|
||||||
})
|
input.onButtonPressed(Button.B, () => {
|
||||||
|
images.createImage(`
|
||||||
|
. . # . .
|
||||||
|
. . # . .
|
||||||
|
# . # . #
|
||||||
|
. # # # .
|
||||||
|
. . # . .
|
||||||
|
`).showImage(0);
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### See also
|
### See also
|
||||||
|
|
||||||
[show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/image/show-image), [scroll image](/reference/image/scroll-image)
|
[Getting Started](/reference/getting-started), [image](/reference/images/image), [show image](/reference/image/show-image),
|
||||||
|
[scroll image](/reference/image/scroll-image), [show animation](/reference/basic/show-animation)
|
||||||
|
Loading…
Reference in New Issue
Block a user