Skip to content

Commit

Permalink
SharkPool/Camera.js: fix speech bubble positions (#1921)
Browse files Browse the repository at this point in the history
Pointed out by Nameless. Thanks!

---------

Co-authored-by: DangoCat[bot] <[email protected]>
  • Loading branch information
SharkPool-SP and DangoCat authored Feb 8, 2025
1 parent 0eb2af5 commit 8d9220b
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions extensions/SharkPool/Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// By: SharkPool
// License: MIT

// Version V.1.0.04
// Version V.1.0.05

(function (Scratch) {
"use strict";
Expand Down Expand Up @@ -136,12 +136,37 @@
const drawable = render._allDrawables[this._dragTarget.drawableID];
if (!drawable[cameraSymbol]) setupState(drawable);
const camSystem = drawable[cameraSymbol];
camSystem.needsRefresh = true;
camSystem.needsRefresh = false;
camSystem.ogXY = [0, 0];
}
ogPostSpriteInfo.call(this, data);
};

const ogGetBubbleBounds = render.getBoundsForBubble;
render.getBoundsForBubble = function (drawableID) {
const drawable = render._allDrawables[drawableID];
if (!drawable[cameraSymbol]) setupState(drawable);
const camSystem = drawable[cameraSymbol];

const bounds = ogGetBubbleBounds.call(this, drawableID);
const realTopLeft = translatePosition(
[bounds.left, bounds.top],
true,
camSystem
);
const realBottomRight = translatePosition(
[bounds.right, bounds.bottom],
true,
camSystem
);

bounds.top = realTopLeft[1];
bounds.left = realTopLeft[0];
bounds.bottom = realBottomRight[1];
bounds.right = realBottomRight[0];
return bounds;
};

const ogUpdatePosition = render.exports.Drawable.prototype.updatePosition;
render.exports.Drawable.prototype.updatePosition = function (position) {
if (!this[cameraSymbol]) setupState(this);
Expand Down

0 comments on commit 8d9220b

Please sign in to comment.