From 25290e7f6a1b091613e1057998f424073048fca9 Mon Sep 17 00:00:00 2001 From: Connor Hudson Date: Tue, 5 Jun 2018 15:58:03 -0400 Subject: [PATCH] Check that bubble bounds do not extend past stage boundaries For when you can't flip the bubble, but need it to remain on-stage --- src/blocks/scratch3_looks.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/blocks/scratch3_looks.js b/src/blocks/scratch3_looks.js index 4a7994a4a..d66e1ce95 100644 --- a/src/blocks/scratch3_looks.js +++ b/src/blocks/scratch3_looks.js @@ -153,10 +153,17 @@ class Scratch3LooksBlocks { this.runtime.renderer.updateDrawableProperties(bubbleState.drawableId, { position: [ bubbleState.onSpriteRight ? ( - Math.min(stageBounds.right - bubbleWidth, targetBounds.right) + Math.max( + stageBounds.left, // Bubble should not extend past left edge of stage + Math.min(stageBounds.right - bubbleWidth, targetBounds.right) + ) ) : ( - Math.max(stageBounds.left, targetBounds.left - bubbleWidth) + Math.min( + stageBounds.right - bubbleWidth, // Bubble should not extend past right edge of stage + Math.max(stageBounds.left, targetBounds.left - bubbleWidth) + ) ), + // Bubble should not extend past the top of the stage Math.min(stageBounds.top, targetBounds.bottom + bubbleHeight) ] });