angry-pixel 2.3.6 → 2.3.7

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/lib/index.d.ts CHANGED
@@ -2631,12 +2631,12 @@ declare enum ButtonShape {
2631
2631
  * @example
2632
2632
  * ```js
2633
2633
  * const tiledWrapper = new TiledWrapper({
2634
- * tilemap: "tilemap.json",
2634
+ * tilemapPath: "tilemap.json",
2635
2635
  * layerToRender: "Ground"
2636
2636
  * });
2637
2637
  *
2638
2638
  * const tiledWrapper = new TiledWrapper({
2639
- * tilemap: assetManager.getJson("tilemap.json"),
2639
+ * tilemapPath: "tilemap.json",
2640
2640
  * layerToRender: "Ground",
2641
2641
  * objects: new Map([
2642
2642
  * ["Player", playerArchetype],
@@ -2647,37 +2647,31 @@ declare enum ButtonShape {
2647
2647
  * ```
2648
2648
  */
2649
2649
  interface TiledWrapperOptions {
2650
- tilemap: TiledTilemap | string;
2650
+ tilemapPath: string;
2651
2651
  layerToRender: string;
2652
2652
  objects: Map<string, TiledObjectBlueprint>;
2653
2653
  }
2654
2654
  /**
2655
2655
  * The TiledWrapper component wraps a Tiled map editor tilemap and handles rendering a specific layer.\
2656
2656
  * It provides an interface between Tiled's map format and the engine's tilemap rendering system.\
2657
- * The tiles animated in Tiled are mapped to the animations of the TilemapRenderer tileset.\
2657
+ * The tilemap is referenced by the URL of its JSON export, and it is loaded if the scene did not load it.\
2658
+ * The tilesets of the TilemapRenderer are created from the ones embedded in the tilemap, unless they are declared,\
2659
+ * so the tilesets need to be embedded in the JSON export.\
2660
+ * The tiles animated in Tiled are mapped to the animations of the tileset they belong to.\
2658
2661
  * It can also create entities from the objects of the tilemap, matching them by class with the `objects` map.
2659
2662
  * @public
2660
2663
  * @category Components
2661
2664
  * @example
2662
2665
  * ```js
2663
2666
  * const tiledWrapper = new TiledWrapper({
2664
- * tilemap: {
2665
- * width: 10,
2666
- * height: 10,
2667
- * infinite: false,
2668
- * layers: [],
2669
- * renderorder: "right-down",
2670
- * tilesets: [{ firstgid: 1 }],
2671
- * tilewidth: 32,
2672
- * tileheight: 32
2673
- * },
2667
+ * tilemapPath: "tilemap/map.json",
2674
2668
  * layerToRender: "Ground"
2675
2669
  * });
2676
2670
  * ```
2677
2671
  */
2678
2672
  declare class TiledWrapper {
2679
- /** The tilemap to render. */
2680
- tilemap: TiledTilemap | string;
2673
+ /** The URL of the JSON tilemap exported from Tiled. It is loaded if the scene did not load it. */
2674
+ tilemapPath: string;
2681
2675
  /** The layer to render. */
2682
2676
  layerToRender: string;
2683
2677
  /**
@@ -2691,8 +2685,12 @@ declare class TiledWrapper {
2691
2685
  _objectsCreated: boolean;
2692
2686
  /** @internal */
2693
2687
  _animationsMapped: boolean;
2694
- /** The coordinates (in tiles) of the top-left corner of the rendered layer. @internal */
2688
+ /** @internal The coordinates (in tiles) of the top-left corner of the rendered layer. */
2695
2689
  _origin: Vector2;
2690
+ /** @internal The tilemap read from the JSON export. */
2691
+ _tilemap: TiledTilemap;
2692
+ /** @internal TRUE if the tilesets of the TilemapRenderer were created from the tilemap. */
2693
+ _tilesetsCreated: boolean;
2696
2694
  /** @internal */
2697
2695
  static componentName: string;
2698
2696
  constructor(options?: Partial<TiledWrapperOptions>);
@@ -3656,6 +3654,10 @@ type Tileset$1 = {
3656
3654
  margin?: number;
3657
3655
  /** Space in pixels between adjacent tiles */
3658
3656
  spacing?: number;
3657
+ /** The id of the first tile of the tileset. Defaults to 1 */
3658
+ firstgid?: number;
3659
+ /** The number of tiles of the tileset. Obtained from the image if it is not set */
3660
+ tileCount?: number;
3659
3661
  /** Maps each animated tile id to the tile id currently displayed. @internal */
3660
3662
  _animationState?: Map<number, number>;
3661
3663
  /** Tileset values in texture coordinates. Computed once by the renderer. @internal */
@@ -3668,6 +3670,10 @@ type Tileset$1 = {
3668
3670
  type TilesetTexData = {
3669
3671
  /** The width of the tileset (in tiles) */
3670
3672
  columns: number;
3673
+ /** The id of the first tile of the tileset */
3674
+ firstgid: number;
3675
+ /** The number of tiles of the tileset */
3676
+ tileCount: number;
3671
3677
  /** The margin of the image */
3672
3678
  margin: Vector2;
3673
3679
  /** The distance between the origin of two adjacent tiles */
@@ -4479,13 +4485,13 @@ declare class TextRenderer {
4479
4485
  * ```js
4480
4486
  * const tilemapRenderer = new TilemapRenderer({
4481
4487
  * layer: "Default",
4482
- * tileset: {
4488
+ * tilesets: [{
4483
4489
  * image: this.assetManager.getImage("tileset.png"),
4484
4490
  * tileWidth: 32,
4485
4491
  * tileHeight: 32,
4486
4492
  * margin: 0,
4487
4493
  * spacing: 0
4488
- * },
4494
+ * }],
4489
4495
  * data: [1, 2, 3, 4],
4490
4496
  * chunks: [],
4491
4497
  * width: 2,
@@ -4502,7 +4508,7 @@ declare class TextRenderer {
4502
4508
  */
4503
4509
  interface TilemapRendererOptions {
4504
4510
  layer: string;
4505
- tileset: Tileset;
4511
+ tilesets: Tileset[];
4506
4512
  data: number[];
4507
4513
  chunks: Chunk[];
4508
4514
  width: number;
@@ -4518,7 +4524,8 @@ interface TilemapRendererOptions {
4518
4524
  }
4519
4525
  /**
4520
4526
  * The TilemapRenderer component renders 2D tile-based maps to the screen.\
4521
- * It uses a tileset image as a source for individual tiles, which are arranged according to a provided array of tile IDs.\
4527
+ * It uses one or more tileset images as a source for individual tiles, which are arranged according to a provided array of tile IDs.\
4528
+ * Each tileset owns the range of ids that starts at its `firstgid` and covers as many tiles as the tileset has.\
4522
4529
  * The component supports features like tinting, masking, opacity control, and custom tile dimensions.\
4523
4530
  * Maps can be rendered in chunks for improved performance with large tilemaps, and tiles can be assigned to specific render layers.\
4524
4531
  * Each tile is referenced by an ID, with 0 representing empty space.
@@ -4528,13 +4535,13 @@ interface TilemapRendererOptions {
4528
4535
  * ```js
4529
4536
  * const tilemapRenderer = new TilemapRenderer({
4530
4537
  * layer: "Default",
4531
- * tileset: {
4538
+ * tilesets: [{
4532
4539
  * image: this.assetManager.getImage("tileset.png"),
4533
4540
  * tileWidth: 32,
4534
4541
  * tileHeight: 32,
4535
4542
  * margin: 0,
4536
4543
  * spacing: 0
4537
- * },
4544
+ * }],
4538
4545
  * data: [1, 2, 3, 4],
4539
4546
  * chunks: [],
4540
4547
  * width: 2,
@@ -4552,8 +4559,11 @@ interface TilemapRendererOptions {
4552
4559
  declare class TilemapRenderer {
4553
4560
  /** The render layer */
4554
4561
  layer: string;
4555
- /** The Tileset instance */
4556
- tileset: Tileset;
4562
+ /**
4563
+ * The tilesets used by the tilemap, each one owning a range of tile ids defined by its `firstgid`.\
4564
+ * They are created by the TiledWrapper when the tilemap comes from Tiled.
4565
+ */
4566
+ tilesets: Tileset[];
4557
4567
  /** Array of tiles. ID 0 (zero) represents empty space.*/
4558
4568
  data: number[];
4559
4569
  /** Array of tile data split into chunks */
@@ -4619,14 +4629,14 @@ interface TileAnimationOptions {
4619
4629
  * @example
4620
4630
  * ```js
4621
4631
  * const tilemapRenderer = new TilemapRenderer({
4622
- * tileset: {
4632
+ * tilesets: [{
4623
4633
  * image: "tileset.png",
4624
4634
  * tileWidth: 32,
4625
4635
  * tileHeight: 32,
4626
4636
  * animations: new Map([
4627
4637
  * [3, new TileAnimation({ tiles: [3, 4, 5], fps: 6 })]
4628
4638
  * ])
4629
- * },
4639
+ * }],
4630
4640
  * data: [1, 2, 3, 4],
4631
4641
  * width: 2
4632
4642
  * });
@@ -4646,8 +4656,10 @@ declare class TileAnimation {
4646
4656
  /**
4647
4657
  * The Tileset configuration defines the properties of a tileset used by the TilemapRenderer.\
4648
4658
  * It specifies the source image containing the tiles, the size of the individual tiles,\
4649
- * and the optional margin and spacing of the image. The number of columns of the tileset\
4650
- * is obtained from the image. The tileset cannot be updated at runtime.
4659
+ * and the optional margin and spacing of the image. The number of columns and the number\
4660
+ * of tiles of the tileset are obtained from the image. When a tilemap uses several tilesets,\
4661
+ * each one needs a `firstgid`, the id of its first tile, following the same criteria as Tiled.\
4662
+ * The tileset cannot be updated at runtime.
4651
4663
  * @public
4652
4664
  * @category Components Configuration
4653
4665
  * @example
@@ -4660,6 +4672,14 @@ declare class TileAnimation {
4660
4672
  * margin: 1,
4661
4673
  * spacing: 2
4662
4674
  * };
4675
+ *
4676
+ * // a second tileset of 16x16 tiles, used by a tilemap whose first tileset has 72 tiles
4677
+ * const anotherTileset = {
4678
+ * image: this.assetManager.getImage("another-tileset.png"),
4679
+ * tileWidth: 16,
4680
+ * tileHeight: 16,
4681
+ * firstgid: 73
4682
+ * };
4663
4683
  * ```
4664
4684
  */
4665
4685
  type Tileset = {
@@ -4671,6 +4691,10 @@ type Tileset = {
4671
4691
  margin?: number;
4672
4692
  /** Space in pixels between adjacent tiles */
4673
4693
  spacing?: number;
4694
+ /** The id of the first tile of the tileset. Defaults to 1 */
4695
+ firstgid?: number;
4696
+ /** The number of tiles of the tileset. Obtained from the image if it is not set */
4697
+ tileCount?: number;
4674
4698
  /** Animated tiles, keyed by the tile id to animate */
4675
4699
  animations?: Map<number, TileAnimation>;
4676
4700
  /** Maps each animated tile id to the tile id currently displayed. @internal */