From 6c59ccbe1b1b32daafce9341c961d2eb172c22f1 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Mon, 30 Apr 2018 14:26:25 -0400 Subject: [PATCH] Use renderer bounds instead of stage bounds for positioning bubbles. Instead of using the rendered bounds of the stage (which can be larger than the actual rendering area of the stage due to large costumes), use the `nativeSize` which is the size in scratch coords of the rendering area. Note that `nativeSize` is not the size of the canvas element or anything like that, it is the "logical size", i.e. the [width, height] in scratch coords. --- src/blocks/scratch3_looks.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/blocks/scratch3_looks.js b/src/blocks/scratch3_looks.js index c676aaa5c..6fbd37d03 100644 --- a/src/blocks/scratch3_looks.js +++ b/src/blocks/scratch3_looks.js @@ -137,7 +137,13 @@ class Scratch3LooksBlocks { bottom: target.y }; } - const stageBounds = this.runtime.getTargetForStage().getBounds(); + const stageSize = this.runtime.renderer.getNativeSize(); + const stageBounds = { + left: -stageSize[0] / 2, + right: stageSize[0] / 2, + top: stageSize[1] / 2, + bottom: -stageSize[1] / 2 + }; if (bubbleState.onSpriteRight && bubbleWidth + targetBounds.right > stageBounds.right && (targetBounds.left - bubbleWidth > stageBounds.left)) { // Only flip if it would fit bubbleState.onSpriteRight = false;