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.
This commit is contained in:
Paul Kaplan 2018-04-30 14:26:25 -04:00
parent 23e72525bf
commit 6c59ccbe1b

View file

@ -137,7 +137,13 @@ class Scratch3LooksBlocks {
bottom: target.y 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 && if (bubbleState.onSpriteRight && bubbleWidth + targetBounds.right > stageBounds.right &&
(targetBounds.left - bubbleWidth > stageBounds.left)) { // Only flip if it would fit (targetBounds.left - bubbleWidth > stageBounds.left)) { // Only flip if it would fit
bubbleState.onSpriteRight = false; bubbleState.onSpriteRight = false;