mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Position the speech bubble more tightly.
This commit is contained in:
parent
5d658b5ecb
commit
ea534b35ea
2 changed files with 14 additions and 2 deletions
|
@ -119,7 +119,7 @@ class Scratch3LooksBlocks {
|
|||
_positionBubble (target) {
|
||||
const bubbleState = this._getBubbleState(target);
|
||||
const [bubbleWidth, bubbleHeight] = this.runtime.renderer.getSkinSize(bubbleState.drawableId);
|
||||
const targetBounds = target.getBounds();
|
||||
const targetBounds = target.getBoundsForBubble();
|
||||
const stageBounds = this.runtime.getTargetForStage().getBounds();
|
||||
if (bubbleState.onSpriteRight && bubbleWidth + targetBounds.right > stageBounds.right &&
|
||||
(targetBounds.left - bubbleWidth > stageBounds.left)) { // Only flip if it would fit
|
||||
|
@ -137,7 +137,7 @@ class Scratch3LooksBlocks {
|
|||
) : (
|
||||
Math.max(stageBounds.left, targetBounds.left - bubbleWidth)
|
||||
),
|
||||
Math.min(stageBounds.top, targetBounds.top + bubbleHeight)
|
||||
Math.min(stageBounds.top, targetBounds.bottom + bubbleHeight)
|
||||
]
|
||||
});
|
||||
this.runtime.requestRedraw();
|
||||
|
|
|
@ -636,6 +636,18 @@ class RenderedTarget extends Target {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the bounding box around a slice of the top 8px of the rendered target.
|
||||
* Includes top, left, bottom, right attributes in Scratch coordinates.
|
||||
* @return {?object} Tight bounding box, or null.
|
||||
*/
|
||||
getBoundsForBubble () {
|
||||
if (this.renderer) {
|
||||
return this.runtime.renderer.getBoundsForBubble(this.drawableID);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether touching a point.
|
||||
* @param {number} x X coordinate of test point.
|
||||
|
|
Loading…
Reference in a new issue