zimporter-phaser 1.0.47 → 1.0.49
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.
package/README.md
CHANGED
|
@@ -281,6 +281,56 @@ The package exposes several classes and methods for interacting with imported as
|
|
|
281
281
|
You can also set a string on the text via the container using:
|
|
282
282
|
`setText(text:string):void`
|
|
283
283
|
|
|
284
|
+
#### `Transform Properties — Orientation-Aware vs Global`
|
|
285
|
+
|
|
286
|
+
`ZContainer` maintains separate transform data for portrait and landscape orientations. Because of this, **position, scale, width, and height must be accessed through `ZContainer` methods** so the values are stored correctly and survive an orientation change:
|
|
287
|
+
|
|
288
|
+
```ts
|
|
289
|
+
container.setX(100);
|
|
290
|
+
container.setY(200);
|
|
291
|
+
container.setScaleX(1.5);
|
|
292
|
+
container.setScaleY(1.5);
|
|
293
|
+
container.setWidth(300);
|
|
294
|
+
container.setHeight(150);
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Setting `x`, `y`, `scaleX`, etc. directly on the object will work visually but the values will be **overwritten** the next time the scene resizes or orientation changes.
|
|
298
|
+
|
|
299
|
+
**Visibility, alpha, and rotation are orientation-independent** — they apply to both portrait and landscape at once, so you can set them directly or via their helper methods:
|
|
300
|
+
|
|
301
|
+
```ts
|
|
302
|
+
container.setVisible(false); // hides in both orientations
|
|
303
|
+
container.setAlpha(0.5); // applies to both orientations
|
|
304
|
+
container.rotation = Math.PI; // applies to both orientations
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
#### `Working with Spine`
|
|
308
|
+
|
|
309
|
+
Spine assets are loaded automatically by the scene. Once the stage is loaded, retrieve the `SpineGameObject` from any `ZContainer` using `getSpine()` and then interact with it through the standard Spine API:
|
|
310
|
+
|
|
311
|
+
```ts
|
|
312
|
+
import { SpineGameObject } from '@esotericsoftware/spine-phaser';
|
|
313
|
+
|
|
314
|
+
const spineContainer = stage.get('mySpineAsset');
|
|
315
|
+
const spineObj: SpineGameObject | undefined = spineContainer?.getSpine();
|
|
316
|
+
|
|
317
|
+
if (spineObj) {
|
|
318
|
+
// Play an animation on track 0, looping
|
|
319
|
+
spineObj.animationState.setAnimation(0, 'run', true);
|
|
320
|
+
|
|
321
|
+
// Change the active skin
|
|
322
|
+
spineObj.skeleton.setSkinByName('mySkin');
|
|
323
|
+
spineObj.skeleton.setToSetupPose();
|
|
324
|
+
|
|
325
|
+
// Listen for animation completion
|
|
326
|
+
spineObj.animationState.addListener({
|
|
327
|
+
complete: (entry) => {
|
|
328
|
+
console.log('Animation complete:', entry.animation?.name);
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
284
334
|
### `ZButton`
|
|
285
335
|
|
|
286
336
|
* Extends `ZContainer`.
|