@unboxy/phaser-sdk 0.2.30 → 0.2.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -251,13 +251,19 @@ function createProgressBar(ctx, entity, pos) {
251
251
  const f = Math.max(0, Math.min(1, frac));
252
252
  g.clear();
253
253
  const radius = v.borderRadius ?? 0;
254
+ // Centered draw: the container is positioned by applyContainerOriginShift
255
+ // so child visuals at (0,0) sit at the resolved anchor; drawing the rect
256
+ // from (-w/2, -h/2) keeps the visual aligned with the editor's
257
+ // editorHit{Width,Height} bounds (which are computed center-based).
258
+ const x0 = -w / 2;
259
+ const y0 = -h / 2;
254
260
  // Background.
255
261
  if (v.backgroundColor) {
256
262
  g.fillStyle(parseColor(v.backgroundColor), 1);
257
263
  if (radius > 0)
258
- g.fillRoundedRect(0, 0, w, h, radius);
264
+ g.fillRoundedRect(x0, y0, w, h, radius);
259
265
  else
260
- g.fillRect(0, 0, w, h);
266
+ g.fillRect(x0, y0, w, h);
261
267
  }
262
268
  // Fill.
263
269
  const fillColor = v.fillColor ?? '#22c55e';
@@ -265,17 +271,17 @@ function createProgressBar(ctx, entity, pos) {
265
271
  const fillW = w * f;
266
272
  if (fillW > 0) {
267
273
  if (radius > 0)
268
- g.fillRoundedRect(0, 0, fillW, h, Math.min(radius, fillW / 2));
274
+ g.fillRoundedRect(x0, y0, fillW, h, Math.min(radius, fillW / 2));
269
275
  else
270
- g.fillRect(0, 0, fillW, h);
276
+ g.fillRect(x0, y0, fillW, h);
271
277
  }
272
278
  // Border.
273
279
  if (v.borderColor && (v.borderWidth ?? 0) > 0) {
274
280
  g.lineStyle(v.borderWidth ?? 1, parseColor(v.borderColor), 1);
275
281
  if (radius > 0)
276
- g.strokeRoundedRect(0, 0, w, h, radius);
282
+ g.strokeRoundedRect(x0, y0, w, h, radius);
277
283
  else
278
- g.strokeRect(0, 0, w, h);
284
+ g.strokeRect(x0, y0, w, h);
279
285
  }
280
286
  };
281
287
  const computeFrac = () => {
@@ -330,19 +336,22 @@ function createPanel(ctx, entity, pos) {
330
336
  const draw = () => {
331
337
  g.clear();
332
338
  const radius = v.borderRadius ?? 0;
339
+ // Centered draw — see createProgressBar for the rationale.
340
+ const x0 = -w / 2;
341
+ const y0 = -h / 2;
333
342
  if (v.backgroundColor) {
334
343
  g.fillStyle(parseColor(v.backgroundColor), v.backgroundAlpha ?? 1);
335
344
  if (radius > 0)
336
- g.fillRoundedRect(0, 0, w, h, radius);
345
+ g.fillRoundedRect(x0, y0, w, h, radius);
337
346
  else
338
- g.fillRect(0, 0, w, h);
347
+ g.fillRect(x0, y0, w, h);
339
348
  }
340
349
  if (v.borderColor && (v.borderWidth ?? 0) > 0) {
341
350
  g.lineStyle(v.borderWidth ?? 1, parseColor(v.borderColor), 1);
342
351
  if (radius > 0)
343
- g.strokeRoundedRect(0, 0, w, h, radius);
352
+ g.strokeRoundedRect(x0, y0, w, h, radius);
344
353
  else
345
- g.strokeRect(0, 0, w, h);
354
+ g.strokeRect(x0, y0, w, h);
346
355
  }
347
356
  };
348
357
  draw();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboxy/phaser-sdk",
3
- "version": "0.2.30",
3
+ "version": "0.2.31",
4
4
  "description": "Unboxy Phaser 3 SDK — game infrastructure for the Unboxy platform",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",