@@ -156,6 +156,52 @@ ProjectScene {
156156 }
157157 }
158158
159+ // Uncomment to display sprite bounding boxes (for debugging)
160+ /* Rectangle {
161+ function translateX(x) {
162+ // Translates Scratch X-coordinate to the scene coordinate system
163+ return root.stageScale * (root.stageWidth / 2 + x)
164+ }
165+
166+ function translateY(y) {
167+ // Translates Scratch Y-coordinate to the scene coordinate system
168+ return root.stageScale * (root.stageHeight / 2 - y)
169+ }
170+
171+ id: boundRect
172+ color: "transparent"
173+ border.color: "red"
174+ border.width: 3
175+
176+ function updatePosition() {
177+ let bounds = targetItem.getQmlBounds();
178+ boundRect.x = translateX(bounds.left);
179+ boundRect.y = translateY(bounds.top);
180+ width = bounds.width * root.stageScale;
181+ height = -bounds.height * root.stageScale;
182+ }
183+
184+ Connections {
185+ target: targetItem
186+
187+ function onXChanged() { boundRect.updatePosition() }
188+ function onYChanged() { boundRect.updatePosition() }
189+ function onRotationChanged() { boundRect.updatePosition() }
190+ function onWidthChanged() { boundRect.updatePosition() }
191+ function onHeightChanged() { boundRect.updatePosition() }
192+ function onScaleChanged() { boundRect.updatePosition() }
193+ }
194+
195+ Connections {
196+ property Scale transform: Scale {}
197+ target: transform
198+
199+ function onXScaleChanged() { boundRect.updatePosition() }
200+
201+ Component.onCompleted: transform = targetItem.transform[0]
202+ }
203+ }*/
204+
159205 Loader {
160206 readonly property alias model: targetItem .spriteModel
161207 active: model ? model .bubbleText !== " " : false
0 commit comments