angry-pixel 2.0.20 → 2.1.0

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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This type represents a dependency class
3
3
  * @public
4
- * @category Core
4
+ * @category Dependency Injection
5
5
  */
6
6
  type DependencyType = {
7
7
  new (...args: any[]): any;
@@ -9,9 +9,14 @@ type DependencyType = {
9
9
  /**
10
10
  * This type represents a dependency name
11
11
  * @public
12
- * @category Core
12
+ * @category Dependency Injection
13
13
  */
14
14
  type DependencyName = string | symbol;
15
+ /**
16
+ * This type represents a property key of a decorator target
17
+ * @public
18
+ * @category Dependency Injection
19
+ */
15
20
  type PropertyKey = string | symbol;
16
21
  declare class Container {
17
22
  private instances;
@@ -347,7 +352,7 @@ declare class Rectangle {
347
352
  * @param rect The target rectangle
348
353
  * @returns TRUE or FALSE
349
354
  */
350
- overlaps(rect: Rectangle): boolean;
355
+ intersects(rect: Rectangle): boolean;
351
356
  /**
352
357
  * Check if the target rectangle is contained
353
358
  *
@@ -362,6 +367,7 @@ declare class Rectangle {
362
367
  * @returns TRUE or FALSE
363
368
  */
364
369
  contains(vector: Vector2): boolean;
370
+ toString(): string;
365
371
  }
366
372
 
367
373
  /**
@@ -613,13 +619,13 @@ interface Collider {
613
619
  /**
614
620
  * This type an unique identifier of an Entity
615
621
  * @public
616
- * @category Core
622
+ * @category Entity-Component-System
617
623
  */
618
624
  type Entity = number;
619
625
  /**
620
626
  * This type represents an instance of a component
621
627
  * @public
622
- * @category Core
628
+ * @category Entity-Component-System
623
629
  */
624
630
  type Component = {
625
631
  [key: string]: any;
@@ -627,7 +633,7 @@ type Component = {
627
633
  /**
628
634
  * This type represents a component class
629
635
  * @public
630
- * @category Core
636
+ * @category Entity-Component-System
631
637
  */
632
638
  type ComponentType<T extends Component = Component> = {
633
639
  new (...args: any[]): T;
@@ -635,7 +641,7 @@ type ComponentType<T extends Component = Component> = {
635
641
  /**
636
642
  * This type represents a search result object
637
643
  * @public
638
- * @category Core
644
+ * @category Entity-Component-System
639
645
  */
640
646
  type SearchResult<T extends Component> = {
641
647
  entity: Entity;
@@ -644,16 +650,91 @@ type SearchResult<T extends Component> = {
644
650
  /**
645
651
  * This type represents a search criteria object
646
652
  * @public
647
- * @category Core
653
+ * @category Entity-Component-System
648
654
  */
649
655
  type SearchCriteria = {
650
656
  [key: string]: any;
651
657
  };
658
+ /**
659
+ * This type represents an Entity Archetype
660
+ * @public
661
+ * @category Entity-Component-System
662
+ */
663
+ type Archetype = {
664
+ components: (ArchetypeComponent | Component)[];
665
+ children?: Archetype[];
666
+ enabled?: boolean;
667
+ };
668
+ /**
669
+ * This type represents an Entity Archetype Component
670
+ * @public
671
+ * @category Entity-Component-System
672
+ */
673
+ type ArchetypeComponent<T extends Component = Component> = {
674
+ type: ComponentType<T>;
675
+ data?: Partial<T>;
676
+ enabled?: boolean;
677
+ };
678
+ /**
679
+ * This interface is used for the creation of system classes. You will have to inject the dependencies you need manully.
680
+ * @public
681
+ * @category Entity-Component-System
682
+ * @example
683
+ * ```typescript
684
+ * class PlayerSystem implements System {
685
+ * @inject(Symbols.EntityManager) private readonly entityManager: EntityManager;
686
+ *
687
+ * public onUpdate() {
688
+ * this.entityManager.search(Player).forEach(({component, entity}) => {
689
+ * // do somethng
690
+ * });
691
+ * }
692
+ * }
693
+ * ```
694
+ */
695
+ interface System {
696
+ /**
697
+ * This method is called the first time the system is enabled
698
+ * @public
699
+ */
700
+ onCreate?(): void;
701
+ /**
702
+ * This method is called when the system is destroyed
703
+ * @public
704
+ */
705
+ onDestroy?(): void;
706
+ /**
707
+ * This method is called when the system is disabled
708
+ * @public
709
+ */
710
+ onDisabled?(): void;
711
+ /**
712
+ * This method is called when the system is enabled
713
+ * @public
714
+ */
715
+ onEnabled?(): void;
716
+ /**
717
+ * This method is called once every frame
718
+ * @public
719
+ */
720
+ onUpdate(): void;
721
+ }
722
+ /**
723
+ * This type represents a system class
724
+ * @public
725
+ * @category Entity-Component-System
726
+ */
727
+ type SystemType<T extends System = System> = {
728
+ new (...args: any[]): T;
729
+ };
730
+ /** @internal */
731
+ type SystemGroup = string | number | symbol;
732
+
652
733
  /**
653
734
  * The EntityManager manages the entities and components.\
654
735
  * It provides the necessary methods for reading and writing entities and components.
655
736
  * @public
656
- * @category Core
737
+ * @category Entity-Component-System
657
738
  */
658
739
  declare class EntityManager {
659
740
  private lastEntityId;
@@ -661,7 +742,10 @@ declare class EntityManager {
661
742
  private entities;
662
743
  private components;
663
744
  private disabledEntities;
745
+ private manuallyDisabledEntities;
664
746
  private disabledComponents;
747
+ private parentEntities;
748
+ private childEntities;
665
749
  /**
666
750
  * Creates an entity without component
667
751
  * @return The created Entity
@@ -672,6 +756,83 @@ declare class EntityManager {
672
756
  * ```
673
757
  */
674
758
  createEntity(): Entity;
759
+ /**
760
+ * Creates an Entity based on an Archetype
761
+ * @param archetype The Archetype to create the Entity
762
+ * @return The created Entity
763
+ * @public
764
+ * @example
765
+ * ```js
766
+ * // Using ArchetypeComponent to define components
767
+ * const entity = entityManager.createEntity({
768
+ * components: [
769
+ * {type: Transform, data: {position: new Vector2(100, 100)}},
770
+ * {type: SpriteRenderer, data: {image: "images/player.png"}},
771
+ * {type: Player},
772
+ * ],
773
+ * children: [
774
+ * {
775
+ * components: [
776
+ * {type: Transform, data: {position: new Vector2(8, 0)}},
777
+ * {type: SpriteRenderer, data: {image: "images/sword.png"}},
778
+ * {type: Weapon, data: {damage: 10}},
779
+ * ],
780
+ * },
781
+ * {
782
+ * components: [
783
+ * {type: Transform, data: {position: new Vector2(-8, 0)}},
784
+ * {type: SpriteRenderer, data: {image: "images/shield.png"}},
785
+ * {type: Shield, data: {defense: 5}, enabled: false},
786
+ * ],
787
+ * },
788
+ * {
789
+ * components: [
790
+ * {type: Transform, data: {position: new Vector2(8, 0)}},
791
+ * {type: SpriteRenderer, data: {image: "images/staf.png"}},
792
+ * {type: Staff, data: {mana: 5}},
793
+ * ],
794
+ * enabled: false,
795
+ * }
796
+ * ]
797
+ * });
798
+ * ```
799
+ * @example
800
+ * ```js
801
+ * // Using Component instances as templates
802
+ * const entity = entityManager.createEntity({
803
+ * components: [
804
+ * new Transform({position: new Vector2(100, 100)}),
805
+ * new SpriteRenderer({image: "images/player.png"}),
806
+ * new Player(),
807
+ * ],
808
+ * children: [
809
+ * {
810
+ * components: [
811
+ * new Transform({position: new Vector2(8, 0)}),
812
+ * new SpriteRenderer({image: "images/sword.png"}),
813
+ * new Weapon({damage: 10}),
814
+ * ],
815
+ * },
816
+ * {
817
+ * components: [
818
+ * new Transform({position: new Vector2(-8, 0)}),
819
+ * new SpriteRenderer({image: "images/shield.png"}),
820
+ * new Shield({defense: 5}),
821
+ * ],
822
+ * },
823
+ * {
824
+ * components: [
825
+ * new Transform({position: new Vector2(8, 0)}),
826
+ * new SpriteRenderer({image: "images/staf.png"}),
827
+ * new Staff({mana: 5}),
828
+ * ],
829
+ * enabled: false,
830
+ * }
831
+ * ]
832
+ * });
833
+ * ```
834
+ */
835
+ createEntity(archetype: Archetype): Entity;
675
836
  /**
676
837
  * Creates an Entity based on a collection of Component instances and ComponentTypes
677
838
  * @param components A collection of component instances and component classes
@@ -685,7 +846,9 @@ declare class EntityManager {
685
846
  * ]);
686
847
  * ```
687
848
  */
688
- createEntity(components: Array<ComponentType | Component>): Entity;
849
+ createEntity(components: Array<ComponentType | Component>, parent?: Entity): Entity;
850
+ private createEntityFromComponents;
851
+ private createEntityFromArchetype;
689
852
  /**
690
853
  * Creates multiple entities based on an array of component collections
691
854
  * @param componentsList An array of collections of component instances and component classes
@@ -693,20 +856,22 @@ declare class EntityManager {
693
856
  * @public
694
857
  * @example
695
858
  * ```js
696
- * const parent = [
859
+ * const player = [
697
860
  * new Transform({position: new Vector2(100, 100)}),
698
- * SpriteRenderer
861
+ * SpriteRenderer,
862
+ * Player
699
863
  * ];
700
864
  *
701
- * const child = [
702
- * new Transform({parent: parent[0]}),
703
- * SpriteRenderer
865
+ * const enemy = [
866
+ * new Transform({position: new Vector2(-100, 100)}),
867
+ * SpriteRenderer,
868
+ * Enemy
704
869
  * ];
705
870
  *
706
- * const entity = entityManager.createEntities([parent, child]);
871
+ * const entities = entityManager.createEntities([player, enemy]);
707
872
  * ```
708
873
  */
709
- createEntities(componentsList: Component[][]): Entity[];
874
+ createEntities(componentsList: Array<ComponentType | Component>[]): Entity[];
710
875
  /**
711
876
  * Removes an Entity and all its Components
712
877
  * @param entity The entity to remove
@@ -748,7 +913,11 @@ declare class EntityManager {
748
913
  */
749
914
  isEntityEnabled(entity: Entity): boolean;
750
915
  /**
751
- * Enables an Entity
916
+ * Enables an Entity.\
917
+ * The entity's components will be included in the `search` results\
918
+ * and therefore will be processed by their respective systems\
919
+ * (the engine built-in systems use the `search` method to retrieve the entities).
920
+ * If the entity has children, they will also be enabled, except for those that have been manually disabled.
752
921
  * @param entity The entity to be enabled
753
922
  * @public
754
923
  * @example
@@ -758,7 +927,11 @@ declare class EntityManager {
758
927
  */
759
928
  enableEntity(entity: Entity): void;
760
929
  /**
761
- * Disables an Entity
930
+ * Disables an entity.\
931
+ * The entity's components will not be included in the `search` results\
932
+ * and therefore will not be processed by their respective systems\
933
+ * (the engine built-in systems use the `search` method to retrieve the entities).
934
+ * If the entity has children, they will also be disabled.
762
935
  * @param entity The entity to be disabled
763
936
  * @public
764
937
  * @example
@@ -787,6 +960,60 @@ declare class EntityManager {
787
960
  * ```
788
961
  */
789
962
  enableEntitiesByComponent(componentType: ComponentType): void;
963
+ /**
964
+ * Sets a parent-child relationship between two entities
965
+ * @param child The child entity
966
+ * @param parent The parent entity
967
+ * @public
968
+ * @example
969
+ * ```js
970
+ * entityManager.setParent(child, parent);
971
+ * ```
972
+ */
973
+ setParent(child: Entity, parent: Entity): void;
974
+ /**
975
+ * Returns the parent entity of the child entity
976
+ * @param child
977
+ * @returns The parent entity
978
+ * @public
979
+ * @example
980
+ * ```js
981
+ * const parent = entityManager.getParent(child);
982
+ * ```
983
+ */
984
+ getParent(child: Entity): Entity;
985
+ /**
986
+ * Returns all child entities of the parent entity
987
+ * @param parent
988
+ * @returns A collection of child entities
989
+ * @public
990
+ * @example
991
+ * ```js
992
+ * const children = entityManager.getChildren(parent);
993
+ * ```
994
+ */
995
+ getChildren(parent: Entity): Entity[];
996
+ /**
997
+ * Removes the parent-child relationship between two entities
998
+ * @param child The child entity
999
+ * @public
1000
+ * @example
1001
+ * ```js
1002
+ * entityManager.removeParent(child);
1003
+ * ```
1004
+ */
1005
+ removeParent(child: Entity): void;
1006
+ /**
1007
+ * Removes a child entity from the parent entity
1008
+ * @param parent The parent entity
1009
+ * @param child The child entity
1010
+ * @public
1011
+ * @example
1012
+ * ```js
1013
+ * entityManager.removeChild(parent, child);
1014
+ * ```
1015
+ */
1016
+ removeChild(parent: Entity, child: Entity): void;
790
1017
  /**
791
1018
  * Adds a component to the entity
792
1019
  * @param entity The Entity to which the component will be added
@@ -944,6 +1171,18 @@ declare class EntityManager {
944
1171
  * ```
945
1172
  */
946
1173
  enableComponent<T extends Component>(entity: Entity, componentType: ComponentType<T>): void;
1174
+ /**
1175
+ * Returns the component of a parent entity, if it exists.
1176
+ * @param parent The parent entity
1177
+ * @param componentType The component class to search
1178
+ * @returns The instance of the component
1179
+ * @public
1180
+ * @example
1181
+ * ```js
1182
+ * const spriteRenderer = entityManager.getComponentFromParent(parent, SpriteRenderer);
1183
+ * ```
1184
+ */
1185
+ getComponentFromParent<T extends Component>(parent: Entity, componentType: ComponentType<T>): T | undefined;
947
1186
  /**
948
1187
  * Performs a search for entities given a component type.\
949
1188
  * This method returns a collection of objects of type SearchResult, which has the entity found, and the instance of the component.\
@@ -968,8 +1207,39 @@ declare class EntityManager {
968
1207
  * // do something with the component and entity
969
1208
  * })
970
1209
  * ```
1210
+ * @example
1211
+ * ```js
1212
+ * const searchResult = entityManager.search(Enemy, {status: "dead"}, true);
1213
+ * searchResult.forEach(({component, entity}) => {
1214
+ * // do something with the component and entity
1215
+ * })
1216
+ * ```
971
1217
  */
972
1218
  search<T extends Component>(componentType: ComponentType<T>, criteria?: SearchCriteria, includeDisabled?: boolean): SearchResult<T>[];
1219
+ /**
1220
+ * Performs a search for entities given a component type.\
1221
+ * This method returns a collection of objects of type SearchResult, which has the entity found, and the instance of the component.\
1222
+ * The second argument determines if disabled entities or components are included in the search result,\its default value is FALSE.
1223
+ * @param componentType The component class
1224
+ * @param includeDisabled TRUE to incluide disabled entities and components, FALSE otherwise
1225
+ * @returns SearchResult
1226
+ * @public
1227
+ * @example
1228
+ * ```js
1229
+ * const searchResult = entityManager.search(SpriteRenderer);
1230
+ * searchResult.forEach(({component, entity}) => {
1231
+ * // do something with the component and entity
1232
+ * })
1233
+ * ```
1234
+ * @example
1235
+ * ```js
1236
+ * const searchResult = entityManager.search(Enemy, true);
1237
+ * searchResult.forEach(({component, entity}) => {
1238
+ * // do something with the component and entity
1239
+ * })
1240
+ * ```
1241
+ */
1242
+ search<T extends Component>(componentType: ComponentType<T>, includeDisabled?: boolean): SearchResult<T>[];
973
1243
  /**
974
1244
  * Performs an entity search given a collection of component types.\
975
1245
  * The entities found must have an instance of all the given component types.\
@@ -983,68 +1253,39 @@ declare class EntityManager {
983
1253
  * ```
984
1254
  */
985
1255
  searchEntitiesByComponents(componentTypes: ComponentType[]): Entity[];
986
- private getComponentTypeId;
987
- }
988
-
989
- /**
990
- * This interface is used for the creation of system classes. You will have to inject the dependencies you need manully.
991
- * @public
992
- * @category Core
993
- * @example
994
- * ```typescript
995
- * class PlayerSystem implements System {
996
- * @inject(Symbols.EntityManager) private readonly entityManager: EntityManager;
997
- *
998
- * public onUpdate() {
999
- * this.entityManager.search(Player).forEach(({component, entity}) => {
1000
- * // do somethng
1001
- * });
1002
- * }
1003
- * }
1004
- * ```
1005
- */
1006
- interface System {
1007
1256
  /**
1008
- * This method is called the first time the system is enabled
1009
- * @public
1010
- */
1011
- onCreate?(): void;
1012
- /**
1013
- * This method is called when the system is destroyed
1014
- * @public
1015
- */
1016
- onDestroy?(): void;
1017
- /**
1018
- * This method is called when the system is disabled
1019
- * @public
1020
- */
1021
- onDisabled?(): void;
1022
- /**
1023
- * This method is called when the system is enabled
1024
- * @public
1025
- */
1026
- onEnabled?(): void;
1027
- /**
1028
- * This method is called once every frame
1257
+ * Performs a search for entities that have a component of the given type and are children of the parent entity.\
1258
+ * This method returns a collection of objects of type SearchResult, which has the entity found, and the instance of the component.\
1259
+ * The third argument determines if disabled entities or components are included in the search result,\its default value is FALSE.
1260
+ * @param parent The parent entity
1261
+ * @param componentType The component class
1262
+ * @param includeDisabled TRUE to incluide disabled entities and components, FALSE otherwise
1263
+ * @returns SearchResult
1029
1264
  * @public
1265
+ * @example
1266
+ * ```js
1267
+ * const searchResult = entityManager.searchInChildren(parent, SpriteRenderer);
1268
+ * searchResult.forEach(({component, entity}) => {
1269
+ * // do something with the component and entity
1270
+ * })
1271
+ * ```
1272
+ * @example
1273
+ * ```js
1274
+ * const searchResult = entityManager.searchInChildren(parent, SpriteRenderer, true);
1275
+ * searchResult.forEach(({component, entity}) => {
1276
+ * // do something with the component and entity
1277
+ * })
1278
+ * ```
1030
1279
  */
1031
- onUpdate(): void;
1280
+ searchInChildren<T extends Component>(parent: Entity, componentType: ComponentType<T>, includeDisabled?: boolean): SearchResult<T>[];
1281
+ private getComponentTypeId;
1032
1282
  }
1033
- /**
1034
- * This type represents a system class
1035
- * @public
1036
- * @category Core
1037
- */
1038
- type SystemType<T extends System = System> = {
1039
- new (...args: any[]): T;
1040
- };
1041
- /** @internal */
1042
- type SystemGroup = string | number | symbol;
1283
+
1043
1284
  /**
1044
1285
  * The SystemManager manages the systems.\
1045
1286
  * It provides the necessary methods for reading and writing systems.
1046
1287
  * @public
1047
- * @category Core
1288
+ * @category Entity-Component-System
1048
1289
  */
1049
1290
  declare class SystemManager {
1050
1291
  private systems;
@@ -1239,12 +1480,19 @@ interface GameConfig {
1239
1480
  width: number;
1240
1481
  /** Game height */
1241
1482
  height: number;
1242
- /** Enables the debug mode */
1243
- debugEnabled?: boolean;
1244
- /** Color of debug elements, default "#00FF00" (green) */
1245
- debugColor?: string;
1246
- /** Position of debug text, default "bottom-left" */
1247
- debugTextPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
1483
+ /** Debug options */
1484
+ debug?: {
1485
+ /** Show colliders */
1486
+ colliders: boolean;
1487
+ /** Show mouse position */
1488
+ mousePosition: boolean;
1489
+ /** Color of the colliders, default "#00FF00" (green) */
1490
+ collidersColor?: string;
1491
+ /** Color of the text, default "#00FF00" (green) */
1492
+ textColor?: string;
1493
+ /** Position of debug text, default "bottom-left" */
1494
+ textPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
1495
+ };
1248
1496
  /** Background color of canvas, default "#000000" (black) */
1249
1497
  canvasColor?: string;
1250
1498
  /** Framerate for physics execution. The allowed values are 60, 120, 180, 240.
@@ -1376,6 +1624,11 @@ declare class AssetManager {
1376
1624
  private createAsset;
1377
1625
  }
1378
1626
 
1627
+ /**
1628
+ * Options for setting an interval.
1629
+ * @public
1630
+ * @category Managers
1631
+ */
1379
1632
  type IntervalOptions = {
1380
1633
  callback: () => void;
1381
1634
  delay: number;
@@ -1729,7 +1982,7 @@ interface AudioPlayerOptions {
1729
1982
  * @category Components
1730
1983
  */
1731
1984
  declare class AudioPlayer {
1732
- /** The action to perform with the audio source. */
1985
+ /** The action to perform with the audio source. This action will be erased at the end of the frame */
1733
1986
  action: AudioPlayerAction;
1734
1987
  /** The audio source to play. */
1735
1988
  audioSource: HTMLAudioElement;
@@ -1737,12 +1990,18 @@ declare class AudioPlayer {
1737
1990
  fixedToTimeScale: boolean;
1738
1991
  /** TRUE If the audio source should loop. */
1739
1992
  loop: boolean;
1740
- /** READONLY, TRUE If the audio source is playing. */
1741
- playing: boolean;
1993
+ /** READONLY, The current state of the audio source. */
1994
+ state: AudioPlayerState;
1742
1995
  /** The volume of the audio source. */
1743
1996
  volume: number;
1997
+ /** READONLY, TRUE If the audio source is playing. */
1998
+ get playing(): boolean;
1999
+ /** READONLY, TRUE If the audio source is paused. */
2000
+ get paused(): boolean;
2001
+ /** READONLY, TRUE If the audio source is stopped. */
2002
+ get stopped(): boolean;
1744
2003
  /** @internal */
1745
- _currentAudioSrc: string;
2004
+ _currentAudioSource: HTMLAudioElement;
1746
2005
  _playPromisePendind: boolean;
1747
2006
  constructor(options?: Partial<AudioPlayerOptions>);
1748
2007
  /**
@@ -1763,6 +2022,11 @@ declare class AudioPlayer {
1763
2022
  * @category Components
1764
2023
  */
1765
2024
  type AudioPlayerAction = "stop" | "play" | "pause";
2025
+ /**
2026
+ * @public
2027
+ * @category Components
2028
+ */
2029
+ type AudioPlayerState = "stopped" | "playing" | "paused";
1766
2030
 
1767
2031
  /**
1768
2032
  * @public
@@ -1814,22 +2078,6 @@ declare enum ButtonShape {
1814
2078
  Circumference = 1
1815
2079
  }
1816
2080
 
1817
- /**
1818
- * @public
1819
- * @category Components
1820
- */
1821
- declare class Children {
1822
- entities: Entity[];
1823
- }
1824
-
1825
- /**
1826
- * @public
1827
- * @category Components
1828
- */
1829
- declare class Parent {
1830
- entity: Entity;
1831
- }
1832
-
1833
2081
  /**
1834
2082
  * @public
1835
2083
  * @category Components
@@ -1958,10 +2206,6 @@ interface TransformOptions {
1958
2206
  position: Vector2;
1959
2207
  scale: Vector2;
1960
2208
  rotation: number;
1961
- parent: Transform;
1962
- localPosition: Vector2;
1963
- localScale: Vector2;
1964
- localRotation: number;
1965
2209
  }
1966
2210
  /**
1967
2211
  * @public
@@ -1981,14 +2225,9 @@ declare class Transform {
1981
2225
  /** The real rotation in the simulated world. It has the same value as `rotation` property if there is no parent */
1982
2226
  localRotation: number;
1983
2227
  /** @internal */
1984
- _parentEntity: Entity;
2228
+ _awake: boolean;
1985
2229
  /** @internal */
1986
- _childEntities: Entity[];
1987
- private _parent;
1988
- /** The parent transform. The position property became relative to this transform */
1989
- get parent(): Transform;
1990
- /** The parent transform. The position property became relative to this transform */
1991
- set parent(parent: Transform);
2230
+ _parent: Transform;
1992
2231
  constructor(options?: Partial<TransformOptions>);
1993
2232
  }
1994
2233
 
@@ -3676,6 +3915,52 @@ declare function gamePreRenderSystem(): (target: SystemType) => void;
3676
3915
  */
3677
3916
  declare function decorate(decorator: (...args: any[]) => any, target: any, propertyKey?: string | symbol | number): void;
3678
3917
 
3918
+ /**
3919
+ * Options for playSfx function.
3920
+ * @public
3921
+ * @category Audio
3922
+ */
3923
+ interface PlaySfxOptions {
3924
+ audioSource: HTMLAudioElement;
3925
+ volume?: number;
3926
+ loop?: boolean;
3927
+ }
3928
+ /**
3929
+ * This funciton is ideal to play one-shot sound effects. It will play the sound effect from the beginning, even if it's already playing.\
3930
+ * You can also use this function to play audio tracks, but it is recommended to use the AudioPlayer component for this. The AudioPlayer component can handle the browser's autoplay policy and other audio-related functions.
3931
+ * @param playSfxOptions - The options for playing the sound effect.
3932
+ * @public
3933
+ * @category Audio
3934
+ * @example
3935
+ * ```javascript
3936
+ * const audioSource = this.assetManager.getAudio("audio/sfx/coin.ogg");
3937
+ * playSfx({ audioSource });
3938
+ * ```
3939
+ * @example
3940
+ * ```javascript
3941
+ * const audioSource = this.assetManager.getAudio("audio/sfx/coin.ogg");
3942
+ * playSfx({ audioSource, volume: 0.5 });
3943
+ * ```
3944
+ * @example
3945
+ * ```javascript
3946
+ * const audioSource = this.assetManager.getAudio("audio/sfx/coin.ogg");
3947
+ * playSfx({ audioSource, loop: true });
3948
+ * ```
3949
+ */
3950
+ declare const playSfx: ({ audioSource, volume, loop }: PlaySfxOptions) => void;
3951
+ /**
3952
+ * Stop a sound effect.
3953
+ * @param audioSource - The audio source to stop.
3954
+ * @public
3955
+ * @category Audio
3956
+ * @example
3957
+ * ```javascript
3958
+ * const audioSource = this.assetManager.getAudio("audio/sfx/coin.ogg");
3959
+ * stopSfx(audioSource);
3960
+ * ```
3961
+ */
3962
+ declare const stopSfx: (audioSource: HTMLAudioElement) => void;
3963
+
3679
3964
  /**
3680
3965
  * Symbols to be used as dependency identifiers
3681
3966
  * @public
@@ -3693,4 +3978,4 @@ declare const Symbols: {
3693
3978
  TimeManager: symbol;
3694
3979
  };
3695
3980
 
3696
- export { Animation, type AnimationSlice, Animator, type AnimatorOptions, AssetManager, AudioPlayer, type AudioPlayerAction, type AudioPlayerOptions, BallCollider, type BallColliderOptions, BoxCollider, type BoxColliderOptions, BroadPhaseMethods, Button, type ButtonOptions, ButtonShape, Camera, type CameraOptions, Children, type Chunk, Circumference, type Collider, type Collision, type CollisionMatrix, CollisionMethods, CollisionRepository, type CollisionResolution, type Component, type ComponentType, type DependencyName, type DependencyType, EdgeCollider, type EdgeColliderOptions, type Entity, EntityManager, Game, type GameConfig, GameSystem, GamepadController, InputManager, type IntervalOptions, Keyboard, LightRenderer, type LightRendererOptions, MaskRenderer, type MaskRendererOptions, MaskShape, Mouse, Parent, Polygon, PolygonCollider, type PolygonColliderOptions, Rectangle, RigidBody, type RigidBodyOptions, RigidBodyType, Scene, SceneManager, type SceneType, type SearchCriteria, type SearchResult, ShadowRenderer, type ShadowRendererOptions, type Shape, type Slice, SpriteRenderer, type SpriteRendererOptions, Symbols, type System, type SystemGroup, SystemManager, type SystemType, TextOrientation, TextRenderer, type TextRendererOptions, type TiledChunk, type TiledLayer, type TiledObject, type TiledObjectLayer, type TiledProperty, type TiledTilemap, TiledWrapper, type TiledWrapperOptions, TilemapCollider, type TilemapColliderOptions, TilemapOrientation, TilemapRenderer, type TilemapRendererOptions, type Tileset, TimeManager, type TouchInteraction, TouchScreen, Transform, type TransformOptions, Vector2, type VibrationInput, VideoRenderer, type VideoRendererOptions, between, clamp, debugRenderLayer, decorate, defaultRenderLayer, defaultTextureAtlasOptions, degreesToRadians, fixedRound, gameLogicSystem, gamePhysicsSystem, gamePreRenderSystem, inject, injectable, radiansToDegrees, randomFloat, randomInt, range, rgbToHex };
3981
+ export { Animation, type AnimationSlice, Animator, type AnimatorOptions, type Archetype, type ArchetypeComponent, AssetManager, AudioPlayer, type AudioPlayerAction, type AudioPlayerOptions, type AudioPlayerState, BallCollider, type BallColliderOptions, BoxCollider, type BoxColliderOptions, BroadPhaseMethods, Button, type ButtonOptions, ButtonShape, Camera, type CameraOptions, type Chunk, Circumference, type Collider, type Collision, type CollisionMatrix, CollisionMethods, CollisionRepository, type CollisionResolution, type Component, type ComponentType, type DependencyName, type DependencyType, EdgeCollider, type EdgeColliderOptions, type Entity, EntityManager, Game, type GameConfig, GameSystem, GamepadController, InputManager, type IntervalOptions, Keyboard, LightRenderer, type LightRendererOptions, MaskRenderer, type MaskRendererOptions, MaskShape, Mouse, type PlaySfxOptions, Polygon, PolygonCollider, type PolygonColliderOptions, type PropertyKey, Rectangle, RigidBody, type RigidBodyOptions, RigidBodyType, Scene, SceneManager, type SceneType, type SearchCriteria, type SearchResult, ShadowRenderer, type ShadowRendererOptions, type Shape, type Slice, SpriteRenderer, type SpriteRendererOptions, Symbols, type System, type SystemGroup, SystemManager, type SystemType, TextOrientation, TextRenderer, type TextRendererOptions, type TiledChunk, type TiledLayer, type TiledObject, type TiledObjectLayer, type TiledProperty, type TiledTilemap, TiledWrapper, type TiledWrapperOptions, TilemapCollider, type TilemapColliderOptions, TilemapOrientation, TilemapRenderer, type TilemapRendererOptions, type Tileset, TimeManager, type TouchInteraction, TouchScreen, Transform, type TransformOptions, Vector2, type VibrationInput, VideoRenderer, type VideoRendererOptions, between, clamp, debugRenderLayer, decorate, defaultRenderLayer, defaultTextureAtlasOptions, degreesToRadians, fixedRound, gameLogicSystem, gamePhysicsSystem, gamePreRenderSystem, inject, injectable, playSfx, radiansToDegrees, randomFloat, randomInt, range, rgbToHex, stopSfx };