From fbb3280bc814141694e4318ae7f256435e4d03b8 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 5 Apr 2018 20:42:03 -0700 Subject: [PATCH] Showimagedelay (#446) * add delay on "show image" * removing optional duration --- libs/ev3/mood.ts | 2 +- libs/screen/targetoverrides.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/ev3/mood.ts b/libs/ev3/mood.ts index 2feee807..9650ed4d 100644 --- a/libs/ev3/mood.ts +++ b/libs/ev3/mood.ts @@ -31,7 +31,7 @@ namespace brick { */ show() { brick.setStatusLight(this.light); - brick.showImage(this.image); + brick.showImage(this.image, 0); music.playSoundEffectUntilDone(this.sound); pause(20); } diff --git a/libs/screen/targetoverrides.ts b/libs/screen/targetoverrides.ts index e2567255..e4e0fe40 100644 --- a/libs/screen/targetoverrides.ts +++ b/libs/screen/targetoverrides.ts @@ -91,13 +91,17 @@ namespace brick { /** * Show an image on the screen * @param image image to draw + * @param duration duration in milliseconds to display the image, eg: 400 */ //% blockId=screen_show_image block="show image %image=screen_image_picker" //% weight=100 group="Screen" blockGap=8 //% help=brick/show-image - export function showImage(image: Image) { + export function showImage(image: Image, duration: number = 400) { if (!image) return; - screen.drawImage(image, 0, 0) + screen.fill(0); + screen.drawImage(image, 0, 0); + if (duration > 0) + pause(duration); } /**