Skip to content

Commit 9293937

Browse files
authored
SharkPool/Camera V2 -- Fix hidden sprites not receiving camera updates (#2372)
This also fixes #2370 Its basically the same code as before the revert, except I added the important line that makes it *not* refresh the camera if the visibility change is the same value is before... this was tested under the same conditions and project @DogeisCut provided
1 parent 92c44ac commit 9293937

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

extensions/SharkPool/Camera.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// By: SharkPool
55
// License: MIT
66

7-
// Version V.1.0.09
7+
// Version V.1.0.1
88

99
(function (Scratch) {
1010
"use strict";
@@ -274,6 +274,23 @@
274274
}
275275
};
276276

277+
const ogUpdateVisible = render.exports.Drawable.prototype.updateVisible;
278+
render.exports.Drawable.prototype.updateVisible = function (isVisible) {
279+
if (!this[cameraSymbol]) setupState(this);
280+
if (isVisible && this._visible !== isVisible) {
281+
// save some renderer calls, packing this all into one
282+
// while running only when isVisible is true combines this
283+
// into a single renderer call
284+
this[cameraSymbol].needsRefresh = true;
285+
this.updateProperties({
286+
position: this._position,
287+
direction: this._direction,
288+
scale: this.scale,
289+
});
290+
}
291+
ogUpdateVisible.call(this, isVisible);
292+
};
293+
277294
// Clones should inherit the parents camera
278295
const ogInitDrawable = vm.exports.RenderedTarget.prototype.initDrawable;
279296
vm.exports.RenderedTarget.prototype.initDrawable = function (layerGroup) {

0 commit comments

Comments
 (0)