angry-pixel 2.1.1 → 2.1.3
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 +5 -5
- package/lib/index.cjs.js +1 -1
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +1107 -316
- package/lib/index.esm.js +1 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -27,7 +27,9 @@ declare class Container {
|
|
|
27
27
|
has(name: DependencyName): boolean;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* Decorator to
|
|
30
|
+
* Decorator to mark a class as an injectable dependency that can be managed by the IoC container.\
|
|
31
|
+
* Injectable classes can be automatically instantiated and have their dependencies resolved when requested through the container.\
|
|
32
|
+
* This enables dependency injection and inversion of control.
|
|
31
33
|
* @param name the name to identify the dependency
|
|
32
34
|
* @public
|
|
33
35
|
* @category Decorators
|
|
@@ -39,7 +41,8 @@ declare class Container {
|
|
|
39
41
|
*/
|
|
40
42
|
declare function injectable(name: DependencyName): (target: DependencyType) => void;
|
|
41
43
|
/**
|
|
42
|
-
* Decorator to
|
|
44
|
+
* Decorator to mark a property or constructor parameter as a dependency that should be automatically injected by the IoC container.\
|
|
45
|
+
* When applied to a property or constructor parameter, the container will resolve and inject the specified dependency at runtime.
|
|
43
46
|
* @param name the name to identify the dependency
|
|
44
47
|
* @public
|
|
45
48
|
* @category Decorators
|
|
@@ -63,7 +66,10 @@ declare function injectable(name: DependencyName): (target: DependencyType) => v
|
|
|
63
66
|
declare function inject(name: DependencyName): (target: any, propertyKey?: PropertyKey, parameterIndex?: number) => void;
|
|
64
67
|
|
|
65
68
|
/**
|
|
66
|
-
* Represents a
|
|
69
|
+
* Represents a two-dimensional vector with x and y components.\
|
|
70
|
+
* Provides static methods for common vector operations
|
|
71
|
+
* like addition, subtraction, scaling, dot product, cross product, normalization and more.\
|
|
72
|
+
* Used throughout the engine for storing 2D positions, directions, velocities and other vector quantities.
|
|
67
73
|
* @category Math
|
|
68
74
|
* @public
|
|
69
75
|
* @example
|
|
@@ -305,9 +311,33 @@ declare class Vector2 {
|
|
|
305
311
|
}
|
|
306
312
|
|
|
307
313
|
/**
|
|
308
|
-
* Represents an axis
|
|
314
|
+
* Represents an axis-aligned bounding rectangle (AABR) defined by position, width and height.
|
|
315
|
+
* The position represents the bottom-left corner of the rectangle.\
|
|
316
|
+
* Provides methods and properties for manipulating and querying the rectangle's geometry.
|
|
309
317
|
* @category Math
|
|
310
318
|
* @public
|
|
319
|
+
* @example
|
|
320
|
+
* ```js
|
|
321
|
+
* const rect = new Rectangle(0, 0, 100, 100);
|
|
322
|
+
* rect.width // 100
|
|
323
|
+
* rect.height // 100
|
|
324
|
+
*
|
|
325
|
+
* rect.x // 0
|
|
326
|
+
* rect.y // 0
|
|
327
|
+
*
|
|
328
|
+
* rect.x1 // 100
|
|
329
|
+
* rect.y1 // 100
|
|
330
|
+
*
|
|
331
|
+
* rect.center // { x: 50, y: 50 }
|
|
332
|
+
*
|
|
333
|
+
* rect.intersects(new Rectangle(50, 50, 100, 100)) // true
|
|
334
|
+
*
|
|
335
|
+
* rect.contains(new Vector2(50, 50)) // true
|
|
336
|
+
*
|
|
337
|
+
* rect.contains(new Rectangle(100, 100, 100, 100)) // false
|
|
338
|
+
*
|
|
339
|
+
* rect.toString() // "(0, 0, 100, 100)"
|
|
340
|
+
* ```
|
|
311
341
|
*/
|
|
312
342
|
declare class Rectangle {
|
|
313
343
|
width: number;
|
|
@@ -371,7 +401,9 @@ declare class Rectangle {
|
|
|
371
401
|
}
|
|
372
402
|
|
|
373
403
|
/**
|
|
374
|
-
*
|
|
404
|
+
* Constrains a number to be within a specified range by clamping it between a minimum and maximum value.\
|
|
405
|
+
* If the value is less than the minimum, returns the minimum. If greater than the maximum, returns the maximum.\
|
|
406
|
+
* Otherwise returns the original value unchanged.
|
|
375
407
|
* @category Math
|
|
376
408
|
* @public
|
|
377
409
|
* @param value number to clamp
|
|
@@ -386,7 +418,8 @@ declare class Rectangle {
|
|
|
386
418
|
*/
|
|
387
419
|
declare const clamp: (value: number, min: number, max: number) => number;
|
|
388
420
|
/**
|
|
389
|
-
* Returns a random integer number between the given minimum and maximum values
|
|
421
|
+
* Returns a random integer number between the given minimum (inclusive) and maximum (inclusive) values.\
|
|
422
|
+
* Uses Math.random() internally to generate the random number, then rounds and scales it to fit the desired range.
|
|
390
423
|
* @category Math
|
|
391
424
|
* @public
|
|
392
425
|
* @param min min value
|
|
@@ -399,7 +432,8 @@ declare const clamp: (value: number, min: number, max: number) => number;
|
|
|
399
432
|
*/
|
|
400
433
|
declare const randomInt: (min: number, max: number) => number;
|
|
401
434
|
/**
|
|
402
|
-
* Returns a random
|
|
435
|
+
* Returns a random floating point number between the given minimum (inclusive) and maximum (inclusive) values.\
|
|
436
|
+
* Uses Math.random() internally to generate the random number and can be rounded to a specified number of decimal places.
|
|
403
437
|
* @category Math
|
|
404
438
|
* @public
|
|
405
439
|
* @param min min value
|
|
@@ -413,7 +447,9 @@ declare const randomInt: (min: number, max: number) => number;
|
|
|
413
447
|
*/
|
|
414
448
|
declare const randomFloat: (min: number, max: number, decimals?: number) => number;
|
|
415
449
|
/**
|
|
416
|
-
*
|
|
450
|
+
* Rounds a floating point number to a specified number of decimal places.\
|
|
451
|
+
* Uses Math.round() internally to avoid floating point precision errors that can occur with direct decimal arithmetic.\
|
|
452
|
+
* For example, 5.2345 rounded to 2 decimal places becomes 5.23.
|
|
417
453
|
* @category Math
|
|
418
454
|
* @public
|
|
419
455
|
* @param value the value to round
|
|
@@ -426,7 +462,9 @@ declare const randomFloat: (min: number, max: number, decimals?: number) => numb
|
|
|
426
462
|
*/
|
|
427
463
|
declare const fixedRound: (value: number, decimals: number) => number;
|
|
428
464
|
/**
|
|
429
|
-
*
|
|
465
|
+
* Generates an array containing a sequence of numbers from start to end (inclusive) with optional step size.\
|
|
466
|
+
* For example, range(0,5) produces [0,1,2,3,4,5] and range(0,10,2) produces [0,2,4,6,8,10].\
|
|
467
|
+
* Useful for creating numeric sequences and iteration ranges.
|
|
430
468
|
* @category Math
|
|
431
469
|
* @public
|
|
432
470
|
* @param start the starting value
|
|
@@ -441,7 +479,9 @@ declare const fixedRound: (value: number, decimals: number) => number;
|
|
|
441
479
|
*/
|
|
442
480
|
declare const range: (start: number, end: number, steps?: number) => number[];
|
|
443
481
|
/**
|
|
444
|
-
*
|
|
482
|
+
* Checks if a number falls within a specified range (inclusive of both minimum and maximum bounds).\
|
|
483
|
+
* Returns true if the value is greater than or equal to the minimum and less than or equal to the maximum.\
|
|
484
|
+
* Useful for range checking, input validation, and boundary testing.
|
|
445
485
|
* @category Math
|
|
446
486
|
* @public
|
|
447
487
|
* @param value number to compare
|
|
@@ -456,7 +496,8 @@ declare const range: (start: number, end: number, steps?: number) => number[];
|
|
|
456
496
|
*/
|
|
457
497
|
declare const between: (value: number, min: number, max: number) => boolean;
|
|
458
498
|
/**
|
|
459
|
-
* Converts
|
|
499
|
+
* Converts an angle from radians to degrees by multiplying by (180/π).\
|
|
500
|
+
* Useful for converting between angular measurement systems and displaying angles in a more human-readable format.
|
|
460
501
|
* @param radians
|
|
461
502
|
* @returns degrees
|
|
462
503
|
* @category Math
|
|
@@ -468,7 +509,8 @@ declare const between: (value: number, min: number, max: number) => boolean;
|
|
|
468
509
|
*/
|
|
469
510
|
declare const radiansToDegrees: (radians: number) => number;
|
|
470
511
|
/**
|
|
471
|
-
* Converts
|
|
512
|
+
* Converts an angle from degrees to radians by multiplying by (π/180).\
|
|
513
|
+
* Useful for converting between angular measurement systems and performing trigonometric calculations.
|
|
472
514
|
* @param degrees
|
|
473
515
|
* @returns radians
|
|
474
516
|
* @category Math
|
|
@@ -480,7 +522,9 @@ declare const radiansToDegrees: (radians: number) => number;
|
|
|
480
522
|
*/
|
|
481
523
|
declare const degreesToRadians: (degrees: number) => number;
|
|
482
524
|
/**
|
|
483
|
-
*
|
|
525
|
+
* Converts RGB color values to a hexadecimal color string.\
|
|
526
|
+
* Takes red, green and blue color components (0-255) and returns a hex color code.\
|
|
527
|
+
* Useful for converting between color formats and generating color strings for CSS/HTML.
|
|
484
528
|
* @param rgb
|
|
485
529
|
* @param prefix default is "#"
|
|
486
530
|
* @returns string
|
|
@@ -569,7 +613,16 @@ declare enum BroadPhaseMethods {
|
|
|
569
613
|
}
|
|
570
614
|
|
|
571
615
|
/**
|
|
572
|
-
* Contains information about the
|
|
616
|
+
* Contains detailed information about a collision between two shapes, including the penetration depth
|
|
617
|
+
* and direction vector. Used to determine how to resolve and separate colliding objects.
|
|
618
|
+
* @example
|
|
619
|
+
* ```typescript
|
|
620
|
+
* // Example collision resolution between two shapes
|
|
621
|
+
* const resolution: CollisionResolution = {
|
|
622
|
+
* penetration: 5, // Shapes overlap by 5 pixels
|
|
623
|
+
* direction: new Vector2(1, 0) // Collision along X axis
|
|
624
|
+
* };
|
|
625
|
+
* ```
|
|
573
626
|
* @public
|
|
574
627
|
* @category Collisions
|
|
575
628
|
*/
|
|
@@ -599,7 +652,8 @@ declare enum CollisionMethods {
|
|
|
599
652
|
}
|
|
600
653
|
|
|
601
654
|
/**
|
|
602
|
-
* Interface
|
|
655
|
+
* Interface defining a collider component that handles collision detection and physics interactions.
|
|
656
|
+
* Colliders define shapes, layers, and physics properties for game objects that can collide.
|
|
603
657
|
* @public
|
|
604
658
|
* @category Collisions
|
|
605
659
|
*/
|
|
@@ -617,29 +671,48 @@ interface Collider {
|
|
|
617
671
|
}
|
|
618
672
|
|
|
619
673
|
/**
|
|
620
|
-
* This type
|
|
674
|
+
* This type represents a unique numeric identifier for an Entity in the ECS system
|
|
621
675
|
* @public
|
|
622
676
|
* @category Entity-Component-System
|
|
623
677
|
*/
|
|
624
678
|
type Entity = number;
|
|
625
679
|
/**
|
|
626
|
-
* This type represents an instance of a component
|
|
680
|
+
* This type represents an instance of a component in the ECS system.\
|
|
681
|
+
* Components are data containers that can be attached to entities\
|
|
682
|
+
* to define their properties and state.\
|
|
683
|
+
* They are implemented as plain objects with key-value pairs.
|
|
627
684
|
* @public
|
|
628
685
|
* @category Entity-Component-System
|
|
686
|
+
* @example
|
|
687
|
+
* ```typescript
|
|
688
|
+
* class PlayerComponent {
|
|
689
|
+
* health: number;
|
|
690
|
+
* speed: number;
|
|
691
|
+
* }
|
|
692
|
+
* ```
|
|
629
693
|
*/
|
|
630
|
-
type Component =
|
|
631
|
-
[key: string]: any;
|
|
632
|
-
};
|
|
694
|
+
type Component = Record<string, any>;
|
|
633
695
|
/**
|
|
634
|
-
* This type represents a component
|
|
696
|
+
* This type represents a constructor function for creating component instances.\
|
|
697
|
+
* Component classes define the structure and behavior of components that can be attached to entities.\
|
|
698
|
+
* They serve as templates/factories for creating component instances with consistent properties and methods.
|
|
635
699
|
* @public
|
|
636
700
|
* @category Entity-Component-System
|
|
701
|
+
* @example
|
|
702
|
+
* ```typescript
|
|
703
|
+
* class PlayerComponent {
|
|
704
|
+
* health: number;
|
|
705
|
+
* speed: number;
|
|
706
|
+
* }
|
|
707
|
+
* ```
|
|
637
708
|
*/
|
|
638
709
|
type ComponentType<T extends Component = Component> = {
|
|
639
710
|
new (...args: any[]): T;
|
|
640
711
|
};
|
|
641
712
|
/**
|
|
642
|
-
* This type represents a search result object
|
|
713
|
+
* This type represents a search result object containing an entity and its matching component.\
|
|
714
|
+
* Used when searching for entities with specific components and criteria.\
|
|
715
|
+
* The generic type T extends Component to provide type safety for the returned component.
|
|
643
716
|
* @public
|
|
644
717
|
* @category Entity-Component-System
|
|
645
718
|
*/
|
|
@@ -648,35 +721,65 @@ type SearchResult<T extends Component> = {
|
|
|
648
721
|
component: T;
|
|
649
722
|
};
|
|
650
723
|
/**
|
|
651
|
-
* This type represents a search criteria object
|
|
724
|
+
* This type represents a search criteria object used to filter components when searching for entities.\
|
|
725
|
+
* It defines a set of key-value pairs where the keys correspond to component properties\
|
|
726
|
+
* and the values are the criteria to match against those properties.
|
|
652
727
|
* @public
|
|
653
728
|
* @category Entity-Component-System
|
|
654
729
|
*/
|
|
655
|
-
type SearchCriteria =
|
|
656
|
-
[key: string]: any;
|
|
657
|
-
};
|
|
730
|
+
type SearchCriteria = Record<string, any>;
|
|
658
731
|
/**
|
|
659
|
-
* This type represents an Entity Archetype
|
|
732
|
+
* This type represents an Entity Archetype, which defines a template for creating entities with a specific set of components.\
|
|
733
|
+
* It specifies which components should be attached to the entity, whether the entity should be enabled/disabled,\
|
|
734
|
+
* and can include child archetypes to create hierarchical entity structures.
|
|
660
735
|
* @public
|
|
661
736
|
* @category Entity-Component-System
|
|
737
|
+
* @example
|
|
738
|
+
* ```typescript
|
|
739
|
+
* // Define an archetype for a player entity with multiple components
|
|
740
|
+
* const playerArchetype: Archetype = {
|
|
741
|
+
* components: [
|
|
742
|
+
* new Transform({position: new Vector2(0, 0)}),
|
|
743
|
+
* new Player({health: 100}),
|
|
744
|
+
* new SpriteRenderer({sprite: 'player.png'})
|
|
745
|
+
* ],
|
|
746
|
+
* };
|
|
747
|
+
*
|
|
748
|
+
* // Define an archetype with disabled components and child entities
|
|
749
|
+
* const enemyArchetype: Archetype = {
|
|
750
|
+
* components: [
|
|
751
|
+
* new Transform(),
|
|
752
|
+
* new Enemy(),
|
|
753
|
+
* disableComponent(new BoxCollider()) // This component starts disabled
|
|
754
|
+
* ],
|
|
755
|
+
* children: [
|
|
756
|
+
* {
|
|
757
|
+
* components: [new WeaponMount()],
|
|
758
|
+
* enabled: false // This child entity starts disabled
|
|
759
|
+
* }
|
|
760
|
+
* ],
|
|
761
|
+
* };
|
|
762
|
+
* ```
|
|
662
763
|
*/
|
|
663
764
|
type Archetype = {
|
|
664
|
-
components: (
|
|
765
|
+
components: (Component | ComponentType | DisabledComponent)[];
|
|
665
766
|
children?: Archetype[];
|
|
666
767
|
enabled?: boolean;
|
|
667
768
|
};
|
|
668
769
|
/**
|
|
669
|
-
* This type represents
|
|
770
|
+
* This type represents a disabled component
|
|
670
771
|
* @public
|
|
671
772
|
* @category Entity-Component-System
|
|
672
773
|
*/
|
|
673
|
-
type
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
enabled?: boolean;
|
|
774
|
+
type DisabledComponent = {
|
|
775
|
+
enabled: false;
|
|
776
|
+
component: Component | ComponentType;
|
|
677
777
|
};
|
|
678
778
|
/**
|
|
679
|
-
* This interface
|
|
779
|
+
* This interface defines the core structure for system classes in the ECS architecture.\
|
|
780
|
+
* Systems contain the game logic that operates on entities and their components.\
|
|
781
|
+
* Dependencies like EntityManager can be injected using dependency injection decorators.\
|
|
782
|
+
* Systems must implement onUpdate() and can optionally implement lifecycle hooks like onCreate(), onDestroy(), onEnabled() and onDisabled().
|
|
680
783
|
* @public
|
|
681
784
|
* @category Entity-Component-System
|
|
682
785
|
* @example
|
|
@@ -720,7 +823,9 @@ interface System {
|
|
|
720
823
|
onUpdate(): void;
|
|
721
824
|
}
|
|
722
825
|
/**
|
|
723
|
-
* This type represents a
|
|
826
|
+
* This type represents a constructor type for System classes.\
|
|
827
|
+
* It defines the shape of a class that can be instantiated to create System objects.\
|
|
828
|
+
* Used for type-safe system registration and retrieval in the SystemManager.
|
|
724
829
|
* @public
|
|
725
830
|
* @category Entity-Component-System
|
|
726
831
|
*/
|
|
@@ -731,10 +836,58 @@ type SystemType<T extends System = System> = {
|
|
|
731
836
|
type SystemGroup = string | number | symbol;
|
|
732
837
|
|
|
733
838
|
/**
|
|
734
|
-
* The EntityManager
|
|
735
|
-
* It provides
|
|
839
|
+
* The EntityManager is responsible for managing the lifecycle and relationships of entities and components.\
|
|
840
|
+
* It provides methods for creating, reading, updating and deleting entities and their associated components.\
|
|
841
|
+
* Handles parent-child relationships between entities and enables/disables entities and components.\
|
|
842
|
+
* Acts as the central registry for all game objects and their behaviors.
|
|
736
843
|
* @public
|
|
737
844
|
* @category Entity-Component-System
|
|
845
|
+
* @example
|
|
846
|
+
* ```js
|
|
847
|
+
* // Create an entity with components
|
|
848
|
+
* const entity = entityManager.createEntity([
|
|
849
|
+
* new Transform({position: new Vector2(100, 100)}),
|
|
850
|
+
* new SpriteRenderer({sprite: "player.png"})
|
|
851
|
+
* ]);
|
|
852
|
+
*
|
|
853
|
+
* // Get a component from an entity
|
|
854
|
+
* const transform = entityManager.getComponent(entity, Transform);
|
|
855
|
+
*
|
|
856
|
+
* // Get all components from an entity
|
|
857
|
+
* const components = entityManager.getComponents(entity);
|
|
858
|
+
*
|
|
859
|
+
* // Find entity by component
|
|
860
|
+
* const entityWithSprite = entityManager.getEntityForComponent(spriteRenderer);
|
|
861
|
+
*
|
|
862
|
+
* // Update component data
|
|
863
|
+
* entityManager.updateComponentData(entity, Transform, {
|
|
864
|
+
* position: new Vector2(200, 200)
|
|
865
|
+
* });
|
|
866
|
+
*
|
|
867
|
+
* // Create parent-child relationship
|
|
868
|
+
* const child = entityManager.createEntity([Transform], parent);
|
|
869
|
+
* // or if you already have the child entity
|
|
870
|
+
* entityManager.setParent(child, parent);
|
|
871
|
+
*
|
|
872
|
+
* // Enable/disable entities
|
|
873
|
+
* entityManager.disableEntity(entity);
|
|
874
|
+
* entityManager.enableEntity(entity);
|
|
875
|
+
*
|
|
876
|
+
* // Remove components
|
|
877
|
+
* entityManager.removeComponent(entity, SpriteRenderer);
|
|
878
|
+
* entityManager.removeComponent(spriteRenderer);
|
|
879
|
+
*
|
|
880
|
+
* // Search for entities with specific components
|
|
881
|
+
* const searchResult = entityManager.search(SpriteRenderer);
|
|
882
|
+
* searchResult.forEach(({component, entity}) => {
|
|
883
|
+
* // do something with the component and entity
|
|
884
|
+
* })
|
|
885
|
+
*
|
|
886
|
+
* const searchResult = entityManager.search(Enemy, {status: "alive"});
|
|
887
|
+
* searchResult.forEach(({component, entity}) => {
|
|
888
|
+
* // do something with the component and entity
|
|
889
|
+
* })
|
|
890
|
+
* ```
|
|
738
891
|
*/
|
|
739
892
|
declare class EntityManager {
|
|
740
893
|
private lastEntityId;
|
|
@@ -757,85 +910,10 @@ declare class EntityManager {
|
|
|
757
910
|
*/
|
|
758
911
|
createEntity(): Entity;
|
|
759
912
|
/**
|
|
760
|
-
* Creates an Entity
|
|
761
|
-
*
|
|
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;
|
|
836
|
-
/**
|
|
837
|
-
* Creates an Entity based on a collection of Component instances and ComponentTypes
|
|
913
|
+
* Creates an Entity with the given components.\
|
|
914
|
+
* Since the components are not cloned, the collection of components must not be reused.
|
|
838
915
|
* @param components A collection of component instances and component classes
|
|
916
|
+
* @param parent The parent entity (optional)
|
|
839
917
|
* @return The created Entity
|
|
840
918
|
* @public
|
|
841
919
|
* @example
|
|
@@ -846,32 +924,35 @@ declare class EntityManager {
|
|
|
846
924
|
* ]);
|
|
847
925
|
* ```
|
|
848
926
|
*/
|
|
849
|
-
createEntity(components:
|
|
850
|
-
private createEntityFromComponents;
|
|
851
|
-
private createEntityFromArchetype;
|
|
927
|
+
createEntity(components: (ComponentType | Component)[], parent?: Entity): Entity;
|
|
852
928
|
/**
|
|
853
|
-
* Creates
|
|
854
|
-
*
|
|
855
|
-
* @
|
|
929
|
+
* Creates an Entity based on an Archetype.\
|
|
930
|
+
* Since the components are cloned, the archetype can be reused to create multiple entities.
|
|
931
|
+
* @param archetype The archetype to create the entity from
|
|
932
|
+
* @param parent The parent entity (optional)
|
|
933
|
+
* @returns The created Entity
|
|
856
934
|
* @public
|
|
857
935
|
* @example
|
|
858
936
|
* ```js
|
|
859
|
-
* const
|
|
860
|
-
*
|
|
861
|
-
*
|
|
862
|
-
*
|
|
863
|
-
*
|
|
864
|
-
*
|
|
865
|
-
*
|
|
866
|
-
*
|
|
867
|
-
*
|
|
868
|
-
* Enemy
|
|
869
|
-
* ];
|
|
870
|
-
*
|
|
871
|
-
* const entities = entityManager.createEntities([player, enemy]);
|
|
937
|
+
* const archetype = {
|
|
938
|
+
* components: [
|
|
939
|
+
* new Transform({position: new Vector2(100, 100)}),
|
|
940
|
+
* SpriteRenderer
|
|
941
|
+
* ],
|
|
942
|
+
* children: [childArchetype],
|
|
943
|
+
* enabled: true
|
|
944
|
+
* }
|
|
945
|
+
* const entity = entityManager.createEntityFromArchetype(archetype);
|
|
872
946
|
* ```
|
|
873
947
|
*/
|
|
874
|
-
|
|
948
|
+
createEntityFromArchetype({ components, children, enabled }: Archetype, parent?: Entity): Entity;
|
|
949
|
+
/**
|
|
950
|
+
* Creates components from an archetype
|
|
951
|
+
* @param components The components to create
|
|
952
|
+
* @param entity The entity to create the components for
|
|
953
|
+
* @private
|
|
954
|
+
*/
|
|
955
|
+
private createComponentsFromArchetype;
|
|
875
956
|
/**
|
|
876
957
|
* Removes an Entity and all its Components
|
|
877
958
|
* @param entity The entity to remove
|
|
@@ -1074,6 +1155,18 @@ declare class EntityManager {
|
|
|
1074
1155
|
* ```
|
|
1075
1156
|
*/
|
|
1076
1157
|
getComponents(entity: Entity): Component[];
|
|
1158
|
+
/**
|
|
1159
|
+
* Updates the data of a component instance
|
|
1160
|
+
* @param entity The entity
|
|
1161
|
+
* @param componentType The component type
|
|
1162
|
+
* @param data The data to update
|
|
1163
|
+
* @public
|
|
1164
|
+
* @example
|
|
1165
|
+
* ```js
|
|
1166
|
+
* entityManager.updateComponentData(entity, Transform, { position: new Vector2(100, 100) });
|
|
1167
|
+
* ```
|
|
1168
|
+
*/
|
|
1169
|
+
updateComponentData<T extends Component = Component>(entity: Entity, componentType: ComponentType<T>, data: Partial<T>): void;
|
|
1077
1170
|
/**
|
|
1078
1171
|
* Searches for and returns an entity for the component instance
|
|
1079
1172
|
* @param component The component instance
|
|
@@ -1282,8 +1375,10 @@ declare class EntityManager {
|
|
|
1282
1375
|
}
|
|
1283
1376
|
|
|
1284
1377
|
/**
|
|
1285
|
-
* The SystemManager
|
|
1286
|
-
* It provides
|
|
1378
|
+
* The SystemManager is responsible for managing the lifecycle and execution of game systems.\
|
|
1379
|
+
* It provides methods for adding, enabling, disabling and retrieving systems that operate on entities and components.\
|
|
1380
|
+
* Systems are organized into groups to control their execution order and update frequency.\
|
|
1381
|
+
* Acts as the central orchestrator for all game logic and behavior processing.
|
|
1287
1382
|
* @public
|
|
1288
1383
|
* @category Entity-Component-System
|
|
1289
1384
|
*/
|
|
@@ -1376,7 +1471,35 @@ declare class SystemManager {
|
|
|
1376
1471
|
}
|
|
1377
1472
|
|
|
1378
1473
|
/**
|
|
1379
|
-
*
|
|
1474
|
+
* Creates a disabled component
|
|
1475
|
+
* @param component The component to disable
|
|
1476
|
+
* @returns The disabled component
|
|
1477
|
+
* @category Entity-Component-System
|
|
1478
|
+
* @public
|
|
1479
|
+
* @example
|
|
1480
|
+
* ```js
|
|
1481
|
+
* const disabledTransform = disableComponent(Transform);
|
|
1482
|
+
* ```
|
|
1483
|
+
*/
|
|
1484
|
+
declare const disableComponent: (component: Component | ComponentType) => DisabledComponent;
|
|
1485
|
+
|
|
1486
|
+
/**
|
|
1487
|
+
* Represents a collision between two entities in the game world. It contains information about the colliding entities,
|
|
1488
|
+
* their collider components, and resolution data for handling the collision response.
|
|
1489
|
+
* @example
|
|
1490
|
+
* ```typescript
|
|
1491
|
+
* // Example collision between player and enemy
|
|
1492
|
+
* const collision: Collision = {
|
|
1493
|
+
* localEntity: playerEntity,
|
|
1494
|
+
* localCollider: playerCollider,
|
|
1495
|
+
* remoteEntity: enemyEntity,
|
|
1496
|
+
* remoteCollider: enemyCollider,
|
|
1497
|
+
* resolution: {
|
|
1498
|
+
* normal: new Vector2(1, 0),
|
|
1499
|
+
* depth: 5
|
|
1500
|
+
* }
|
|
1501
|
+
* };
|
|
1502
|
+
* ```
|
|
1380
1503
|
* @category Collisions
|
|
1381
1504
|
* @public
|
|
1382
1505
|
*/
|
|
@@ -1409,9 +1532,25 @@ interface Collision {
|
|
|
1409
1532
|
}
|
|
1410
1533
|
|
|
1411
1534
|
/**
|
|
1412
|
-
* The CollisionRepository
|
|
1535
|
+
* The CollisionRepository stores and manages collision data between colliders.
|
|
1536
|
+
* It provides methods for querying collisions by collider and layer,
|
|
1537
|
+
* and handles persisting/removing collision records.
|
|
1413
1538
|
* @public
|
|
1414
1539
|
* @category Collisions
|
|
1540
|
+
* @example
|
|
1541
|
+
* ```typescript
|
|
1542
|
+
* // Get all collisions for a collider
|
|
1543
|
+
* const collisions = collisionRepository.findCollisionsForCollider(playerCollider);
|
|
1544
|
+
*
|
|
1545
|
+
* // Get collisions between player and enemies
|
|
1546
|
+
* const enemyCollisions = collisionRepository.findCollisionsForColliderAndLayer(
|
|
1547
|
+
* playerCollider,
|
|
1548
|
+
* "enemy"
|
|
1549
|
+
* );
|
|
1550
|
+
*
|
|
1551
|
+
* // Get all current collisions
|
|
1552
|
+
* const allCollisions = collisionRepository.findAll();
|
|
1553
|
+
* ```
|
|
1415
1554
|
*/
|
|
1416
1555
|
declare class CollisionRepository {
|
|
1417
1556
|
private collisions;
|
|
@@ -1448,7 +1587,10 @@ declare class CollisionRepository {
|
|
|
1448
1587
|
type CollisionMatrix = [string, string][];
|
|
1449
1588
|
|
|
1450
1589
|
/**
|
|
1451
|
-
*
|
|
1590
|
+
* Configuration options for initializing and customizing game behavior.
|
|
1591
|
+
* Includes settings for canvas dimensions, debug visualization, physics simulation,
|
|
1592
|
+
* collision detection, and dependency injection.\
|
|
1593
|
+
* Required for creating a new Game instance.
|
|
1452
1594
|
* @public
|
|
1453
1595
|
* @category Config
|
|
1454
1596
|
* @example
|
|
@@ -1524,7 +1666,9 @@ declare class CreateSystemService {
|
|
|
1524
1666
|
}
|
|
1525
1667
|
|
|
1526
1668
|
/**
|
|
1527
|
-
* Manages
|
|
1669
|
+
* Manages loading and retrieval of game assets including images, fonts, audio files, videos and JSON data.\
|
|
1670
|
+
* Provides methods to load assets asynchronously and check their loading status.\
|
|
1671
|
+
* Assets can be referenced by URL or optional name identifiers.
|
|
1528
1672
|
* @public
|
|
1529
1673
|
* @category Managers
|
|
1530
1674
|
* @example
|
|
@@ -1533,12 +1677,14 @@ declare class CreateSystemService {
|
|
|
1533
1677
|
* this.assetManager.loadAudio("audio.ogg");
|
|
1534
1678
|
* this.assetManager.loadVideo("video.mp4");
|
|
1535
1679
|
* this.assetManager.loadFont("custom-font", "custom-font.ttf");
|
|
1680
|
+
* this.assetManager.loadJson("data.json");
|
|
1536
1681
|
*
|
|
1537
1682
|
* const imageElement = this.assetManager.getImage("image.png");
|
|
1538
1683
|
* const audioElement = this.assetManager.getAudio("audio.ogg");
|
|
1539
1684
|
* const videoElement = this.assetManager.getVideo("video.mp4");
|
|
1540
1685
|
* const fontFace = this.assetManager.getFont("custom-font");
|
|
1541
|
-
*
|
|
1686
|
+
* const jsonData = this.assetManager.getJson("data.json");
|
|
1687
|
+
|
|
1542
1688
|
* if (this.assetManager.getAssetsLoaded()) {
|
|
1543
1689
|
* // do something when assets are loaded
|
|
1544
1690
|
* }
|
|
@@ -1641,21 +1787,41 @@ declare class AssetManager {
|
|
|
1641
1787
|
*/
|
|
1642
1788
|
getJson<T = Record<string, any>>(name: string): T;
|
|
1643
1789
|
private createAsset;
|
|
1790
|
+
private deleteAssetIfExists;
|
|
1644
1791
|
}
|
|
1645
1792
|
|
|
1646
1793
|
/**
|
|
1647
|
-
* Options for
|
|
1794
|
+
* Options for configuring an interval timer.
|
|
1795
|
+
* @property {Function} callback - The function to execute at each interval
|
|
1796
|
+
* @property {number} delay - The time in milliseconds between each execution
|
|
1797
|
+
* @property {number} [times] - Optional number of times to execute before auto-clearing. Omit for infinite execution.
|
|
1798
|
+
* @property {boolean} [executeImmediately] - Whether to execute the callback immediately before starting the interval timer
|
|
1648
1799
|
* @public
|
|
1649
1800
|
* @category Managers
|
|
1801
|
+
* @example
|
|
1802
|
+
* ```ts
|
|
1803
|
+
* const intervalId = timeManager.setInterval({
|
|
1804
|
+
* callback: () => console.log("Will be called 5 times!"),
|
|
1805
|
+
* delay: 1000,
|
|
1806
|
+
* times: 5,
|
|
1807
|
+
* });
|
|
1808
|
+
* ```
|
|
1650
1809
|
*/
|
|
1651
1810
|
type IntervalOptions = {
|
|
1811
|
+
/** The function to execute at each interval */
|
|
1652
1812
|
callback: () => void;
|
|
1813
|
+
/** The time in milliseconds between each execution */
|
|
1653
1814
|
delay: number;
|
|
1815
|
+
/** Optional number of times to execute before auto-clearing. Omit for infinite execution. */
|
|
1654
1816
|
times?: number;
|
|
1817
|
+
/** Whether to execute the callback immediately before starting the interval timer */
|
|
1655
1818
|
executeImmediately?: boolean;
|
|
1656
1819
|
};
|
|
1657
1820
|
/**
|
|
1658
|
-
* Manages the properties associated with time
|
|
1821
|
+
* Manages the properties associated with time.\
|
|
1822
|
+
* Provides methods to set intervals, clear intervals, and manage time scaling.\
|
|
1823
|
+
* Manages the fixed game framerate and physics framerate.\
|
|
1824
|
+
* Manages the fixed game delta time and physics delta time.
|
|
1659
1825
|
* @public
|
|
1660
1826
|
* @category Managers
|
|
1661
1827
|
* @example
|
|
@@ -1783,13 +1949,17 @@ declare class TimeManager {
|
|
|
1783
1949
|
/**
|
|
1784
1950
|
* This type represents a scene class
|
|
1785
1951
|
* @public
|
|
1786
|
-
* @category
|
|
1952
|
+
* @category Managers
|
|
1787
1953
|
*/
|
|
1788
1954
|
type SceneType<T extends Scene = Scene> = {
|
|
1789
1955
|
new (entityManager: EntityManager, assetManager: AssetManager): T;
|
|
1790
1956
|
};
|
|
1791
1957
|
/**
|
|
1792
|
-
* Base class for all game scenes
|
|
1958
|
+
* Base class for all game scenes.\
|
|
1959
|
+
* Provides core functionality for loading assets, registering systems, and setting up entities.\
|
|
1960
|
+
* Scenes are the main organizational unit for game states and levels.\
|
|
1961
|
+
* Each scene has access to the EntityManager for creating/managing entities and the AssetManager
|
|
1962
|
+
* for loading and accessing game resources.
|
|
1793
1963
|
* @public
|
|
1794
1964
|
* @category Core
|
|
1795
1965
|
* @example
|
|
@@ -1825,7 +1995,9 @@ declare abstract class Scene {
|
|
|
1825
1995
|
setup(): void;
|
|
1826
1996
|
}
|
|
1827
1997
|
/**
|
|
1828
|
-
*
|
|
1998
|
+
* Manages scene loading, transitions and lifecycle.\
|
|
1999
|
+
* Provides methods to register scenes, load scenes by name, and handles the opening scene.\
|
|
2000
|
+
* Ensures proper cleanup between scene transitions and maintains scene state.
|
|
1829
2001
|
* @public
|
|
1830
2002
|
* @category Managers
|
|
1831
2003
|
* @example
|
|
@@ -1858,11 +2030,17 @@ declare class SceneManager {
|
|
|
1858
2030
|
}
|
|
1859
2031
|
|
|
1860
2032
|
/**
|
|
1861
|
-
* Game
|
|
2033
|
+
* The Game class is the core entry point for creating and managing a game instance.\
|
|
2034
|
+
* It serves as a central hub that coordinates all game systems including scenes, entities,
|
|
2035
|
+
* components, and various managers (rendering, physics, input, etc.).\
|
|
2036
|
+
* The class provides methods to initialize the game with custom configuration, add scenes
|
|
2037
|
+
* and dependencies, and control the game loop execution.\
|
|
2038
|
+
* Through dependency injection, it ensures proper initialization and communication between all game systems.
|
|
1862
2039
|
* @public
|
|
1863
2040
|
* @category Core
|
|
1864
2041
|
* @example
|
|
1865
2042
|
* ```js
|
|
2043
|
+
* // Basic game setup with minimal configuration
|
|
1866
2044
|
* const game = new Game({
|
|
1867
2045
|
* containerNode: document.getElementById("app"),
|
|
1868
2046
|
* width: 1920,
|
|
@@ -1873,6 +2051,7 @@ declare class SceneManager {
|
|
|
1873
2051
|
* ```
|
|
1874
2052
|
* @example
|
|
1875
2053
|
* ```js
|
|
2054
|
+
* // Advanced game setup with custom physics and collision settings
|
|
1876
2055
|
* const game = new Game({
|
|
1877
2056
|
* containerNode: document.getElementById("app"),
|
|
1878
2057
|
* width: 1920,
|
|
@@ -1933,8 +2112,35 @@ declare class Game {
|
|
|
1933
2112
|
}
|
|
1934
2113
|
|
|
1935
2114
|
/**
|
|
2115
|
+
* Animator component configuration
|
|
1936
2116
|
* @public
|
|
1937
|
-
* @category Components
|
|
2117
|
+
* @category Components Configuration
|
|
2118
|
+
* @example
|
|
2119
|
+
* ```js
|
|
2120
|
+
* const walkAnimation = new Animation({
|
|
2121
|
+
* image: "walk.png",
|
|
2122
|
+
* slice: { size: new Vector2(32, 32) },
|
|
2123
|
+
* fps: 12,
|
|
2124
|
+
* loop: true
|
|
2125
|
+
* });
|
|
2126
|
+
*
|
|
2127
|
+
* const idleAnimation = new Animation({
|
|
2128
|
+
* image: "idle.png",
|
|
2129
|
+
* slice: { size: new Vector2(32, 32) },
|
|
2130
|
+
* fps: 8,
|
|
2131
|
+
* loop: true
|
|
2132
|
+
* });
|
|
2133
|
+
*
|
|
2134
|
+
* const animator = new Animator({
|
|
2135
|
+
* animations: new Map([
|
|
2136
|
+
* ["walk", walkAnimation],
|
|
2137
|
+
* ["idle", idleAnimation]
|
|
2138
|
+
* ]),
|
|
2139
|
+
* animation: "idle",
|
|
2140
|
+
* speed: 1,
|
|
2141
|
+
* playing: true
|
|
2142
|
+
* });
|
|
2143
|
+
* ```
|
|
1938
2144
|
*/
|
|
1939
2145
|
interface AnimatorOptions {
|
|
1940
2146
|
animations: Map<string, Animation>;
|
|
@@ -1943,8 +2149,36 @@ interface AnimatorOptions {
|
|
|
1943
2149
|
playing: boolean;
|
|
1944
2150
|
}
|
|
1945
2151
|
/**
|
|
2152
|
+
* The Animator component manages sprite animations. It holds a map of named animations
|
|
2153
|
+
* and controls which animation is currently playing, its speed, and playback state.
|
|
1946
2154
|
* @public
|
|
1947
2155
|
* @category Components
|
|
2156
|
+
* @example
|
|
2157
|
+
* ```js
|
|
2158
|
+
* const walkAnimation = new Animation({
|
|
2159
|
+
* image: "walk.png",
|
|
2160
|
+
* slice: { size: new Vector2(32, 32) },
|
|
2161
|
+
* fps: 12,
|
|
2162
|
+
* loop: true
|
|
2163
|
+
* });
|
|
2164
|
+
*
|
|
2165
|
+
* const idleAnimation = new Animation({
|
|
2166
|
+
* image: "idle.png",
|
|
2167
|
+
* slice: { size: new Vector2(32, 32) },
|
|
2168
|
+
* fps: 8,
|
|
2169
|
+
* loop: true
|
|
2170
|
+
* });
|
|
2171
|
+
*
|
|
2172
|
+
* const animator = new Animator({
|
|
2173
|
+
* animations: new Map([
|
|
2174
|
+
* ["walk", walkAnimation],
|
|
2175
|
+
* ["idle", idleAnimation]
|
|
2176
|
+
* ]),
|
|
2177
|
+
* animation: "idle",
|
|
2178
|
+
* speed: 1,
|
|
2179
|
+
* playing: true
|
|
2180
|
+
* });
|
|
2181
|
+
* ```
|
|
1948
2182
|
*/
|
|
1949
2183
|
declare class Animator {
|
|
1950
2184
|
animations: Map<string, Animation>;
|
|
@@ -1956,23 +2190,95 @@ declare class Animator {
|
|
|
1956
2190
|
currentTime: number;
|
|
1957
2191
|
/** @internal */
|
|
1958
2192
|
_currentAnimation: string;
|
|
2193
|
+
/** @internal */
|
|
2194
|
+
_assetsReady: boolean;
|
|
1959
2195
|
constructor(options?: Partial<AnimatorOptions>);
|
|
1960
2196
|
}
|
|
1961
2197
|
/**
|
|
2198
|
+
* Animation configuration
|
|
1962
2199
|
* @public
|
|
1963
|
-
* @category Components
|
|
2200
|
+
* @category Components Configuration
|
|
2201
|
+
* @example
|
|
2202
|
+
* ```js
|
|
2203
|
+
* const walkAnimation = new Animation({
|
|
2204
|
+
* image: "walk.png",
|
|
2205
|
+
* slice: { size: new Vector2(32, 32) },
|
|
2206
|
+
* fps: 12,
|
|
2207
|
+
* loop: true
|
|
2208
|
+
* });
|
|
2209
|
+
*
|
|
2210
|
+
* const idleAnimation = new Animation({
|
|
2211
|
+
* image: "idle.png",
|
|
2212
|
+
* slice: { size: new Vector2(32, 32) },
|
|
2213
|
+
* fps: 8,
|
|
2214
|
+
* loop: true
|
|
2215
|
+
* });
|
|
2216
|
+
*
|
|
2217
|
+
* const animator = new Animator({
|
|
2218
|
+
* animations: new Map([
|
|
2219
|
+
* ["walk", walkAnimation],
|
|
2220
|
+
* ["idle", idleAnimation]
|
|
2221
|
+
* ]),
|
|
2222
|
+
* animation: "idle",
|
|
2223
|
+
* speed: 1,
|
|
2224
|
+
* playing: true
|
|
2225
|
+
* });
|
|
2226
|
+
* ```
|
|
2227
|
+
*/
|
|
2228
|
+
interface AnimationOptions {
|
|
2229
|
+
image: HTMLImageElement | HTMLImageElement[] | string | string[];
|
|
2230
|
+
slice?: {
|
|
2231
|
+
size: Vector2;
|
|
2232
|
+
offset?: Vector2;
|
|
2233
|
+
padding?: Vector2;
|
|
2234
|
+
};
|
|
2235
|
+
frames?: number[];
|
|
2236
|
+
fps?: number;
|
|
2237
|
+
loop?: boolean;
|
|
2238
|
+
}
|
|
2239
|
+
/**
|
|
2240
|
+
* Animation class used to configure sprite animations. It defines properties like the source image(s),
|
|
2241
|
+
* slice dimensions for sprite sheets, frame sequence, playback speed and looping behavior.
|
|
2242
|
+
* @public
|
|
2243
|
+
* @category Components Configuration
|
|
2244
|
+
* @example
|
|
2245
|
+
* ```js
|
|
2246
|
+
* const walkAnimation = new Animation({
|
|
2247
|
+
* image: "walk.png",
|
|
2248
|
+
* slice: { size: new Vector2(32, 32) },
|
|
2249
|
+
* fps: 12,
|
|
2250
|
+
* loop: true
|
|
2251
|
+
* });
|
|
2252
|
+
*
|
|
2253
|
+
* const idleAnimation = new Animation({
|
|
2254
|
+
* image: "idle.png",
|
|
2255
|
+
* slice: { size: new Vector2(32, 32) },
|
|
2256
|
+
* fps: 8,
|
|
2257
|
+
* loop: true
|
|
2258
|
+
* });
|
|
2259
|
+
*
|
|
2260
|
+
* const animator = new Animator({
|
|
2261
|
+
* animations: new Map([
|
|
2262
|
+
* ["walk", walkAnimation],
|
|
2263
|
+
* ["idle", idleAnimation]
|
|
2264
|
+
* ]),
|
|
2265
|
+
* animation: "idle",
|
|
2266
|
+
* speed: 1,
|
|
2267
|
+
* playing: true
|
|
2268
|
+
* });
|
|
2269
|
+
* ```
|
|
1964
2270
|
*/
|
|
1965
2271
|
declare class Animation {
|
|
1966
|
-
image: HTMLImageElement | HTMLImageElement[];
|
|
2272
|
+
image: HTMLImageElement | HTMLImageElement[] | string | string[];
|
|
1967
2273
|
slice: AnimationSlice;
|
|
1968
2274
|
frames: number[];
|
|
1969
2275
|
fps: number;
|
|
1970
2276
|
loop: boolean;
|
|
1971
|
-
constructor(options?:
|
|
2277
|
+
constructor(options?: AnimationOptions);
|
|
1972
2278
|
}
|
|
1973
2279
|
/**
|
|
1974
2280
|
* @public
|
|
1975
|
-
* @category Components
|
|
2281
|
+
* @category Components Configuration
|
|
1976
2282
|
*/
|
|
1977
2283
|
type AnimationSlice = {
|
|
1978
2284
|
size: Vector2;
|
|
@@ -1981,14 +2287,24 @@ type AnimationSlice = {
|
|
|
1981
2287
|
};
|
|
1982
2288
|
|
|
1983
2289
|
/**
|
|
2290
|
+
* AudioPlayer component configuration
|
|
1984
2291
|
* @public
|
|
1985
|
-
* @category Components
|
|
2292
|
+
* @category Components Configuration
|
|
2293
|
+
* @example
|
|
2294
|
+
* ```js
|
|
2295
|
+
* const audioPlayer = new AudioPlayer({
|
|
2296
|
+
* audioSource: "sound.mp3",
|
|
2297
|
+
* volume: 0.5,
|
|
2298
|
+
* loop: true,
|
|
2299
|
+
* fixedToTimeScale: false
|
|
2300
|
+
* });
|
|
2301
|
+
* ```
|
|
1986
2302
|
*/
|
|
1987
2303
|
interface AudioPlayerOptions {
|
|
1988
2304
|
/** The action to perform with the audio source. */
|
|
1989
2305
|
action: AudioPlayerAction;
|
|
1990
2306
|
/** The audio source to play. */
|
|
1991
|
-
audioSource: HTMLAudioElement;
|
|
2307
|
+
audioSource: HTMLAudioElement | string;
|
|
1992
2308
|
/** TRUE If the playback rate is fixed to the TimeManager time scale, default FALSE */
|
|
1993
2309
|
fixedToTimeScale: boolean;
|
|
1994
2310
|
/** TRUE If the audio source should loop. */
|
|
@@ -1997,14 +2313,25 @@ interface AudioPlayerOptions {
|
|
|
1997
2313
|
volume: number;
|
|
1998
2314
|
}
|
|
1999
2315
|
/**
|
|
2316
|
+
* The AudioPlayer component handles audio playback in the game. It manages playing, pausing and stopping audio sources,
|
|
2317
|
+
* controls volume and looping behavior, and can optionally sync playback speed with the game's time scale.
|
|
2000
2318
|
* @public
|
|
2001
2319
|
* @category Components
|
|
2320
|
+
* @example
|
|
2321
|
+
* ```js
|
|
2322
|
+
* const audioPlayer = new AudioPlayer({
|
|
2323
|
+
* audioSource: "sound.mp3",
|
|
2324
|
+
* volume: 0.5,
|
|
2325
|
+
* loop: true,
|
|
2326
|
+
* fixedToTimeScale: false
|
|
2327
|
+
* });
|
|
2328
|
+
* ```
|
|
2002
2329
|
*/
|
|
2003
2330
|
declare class AudioPlayer {
|
|
2004
2331
|
/** The action to perform with the audio source. This action will be erased at the end of the frame */
|
|
2005
2332
|
action: AudioPlayerAction;
|
|
2006
2333
|
/** The audio source to play. */
|
|
2007
|
-
audioSource: HTMLAudioElement;
|
|
2334
|
+
audioSource: HTMLAudioElement | string;
|
|
2008
2335
|
/** TRUE If the playback rate is fixed to the TimeManager time scale, default FALSE */
|
|
2009
2336
|
fixedToTimeScale: boolean;
|
|
2010
2337
|
/** TRUE If the audio source should loop. */
|
|
@@ -2022,6 +2349,7 @@ declare class AudioPlayer {
|
|
|
2022
2349
|
/** @internal */
|
|
2023
2350
|
_currentAudioSource: HTMLAudioElement;
|
|
2024
2351
|
_playPromisePendind: boolean;
|
|
2352
|
+
_playAfterUserInput: boolean;
|
|
2025
2353
|
constructor(options?: Partial<AudioPlayerOptions>);
|
|
2026
2354
|
/**
|
|
2027
2355
|
* Play the audio source.
|
|
@@ -2038,18 +2366,31 @@ declare class AudioPlayer {
|
|
|
2038
2366
|
}
|
|
2039
2367
|
/**
|
|
2040
2368
|
* @public
|
|
2041
|
-
* @category Components
|
|
2369
|
+
* @category Components Configuration
|
|
2042
2370
|
*/
|
|
2043
2371
|
type AudioPlayerAction = "stop" | "play" | "pause";
|
|
2044
2372
|
/**
|
|
2045
2373
|
* @public
|
|
2046
|
-
* @category Components
|
|
2374
|
+
* @category Components Configuration
|
|
2047
2375
|
*/
|
|
2048
2376
|
type AudioPlayerState = "stopped" | "playing" | "paused";
|
|
2049
2377
|
|
|
2050
2378
|
/**
|
|
2379
|
+
* Button component configuration
|
|
2051
2380
|
* @public
|
|
2052
|
-
* @category Components
|
|
2381
|
+
* @category Components Configuration
|
|
2382
|
+
* @example
|
|
2383
|
+
* ```js
|
|
2384
|
+
* const button = new Button({
|
|
2385
|
+
* shape: ButtonShape.Rectangle,
|
|
2386
|
+
* width: 100,
|
|
2387
|
+
* height: 50,
|
|
2388
|
+
* offset: new Vector2(0, 0),
|
|
2389
|
+
* touchEnabled: true,
|
|
2390
|
+
* onClick: () => console.log("Button clicked!"),
|
|
2391
|
+
* onPressed: () => console.log("Button pressed!")
|
|
2392
|
+
* });
|
|
2393
|
+
* ```
|
|
2053
2394
|
*/
|
|
2054
2395
|
interface ButtonOptions {
|
|
2055
2396
|
shape: ButtonShape;
|
|
@@ -2062,8 +2403,23 @@ interface ButtonOptions {
|
|
|
2062
2403
|
onPressed: () => void;
|
|
2063
2404
|
}
|
|
2064
2405
|
/**
|
|
2406
|
+
* The Button component creates an interactive button that can be clicked or pressed.\
|
|
2407
|
+
* It supports rectangular or circular shapes and can be configured with dimensions,
|
|
2408
|
+
* position offset, touch input, and click/press event handlers.
|
|
2065
2409
|
* @public
|
|
2066
2410
|
* @category Components
|
|
2411
|
+
* @example
|
|
2412
|
+
* ```js
|
|
2413
|
+
* const button = new Button({
|
|
2414
|
+
* shape: ButtonShape.Rectangle,
|
|
2415
|
+
* width: 100,
|
|
2416
|
+
* height: 50,
|
|
2417
|
+
* offset: new Vector2(0, 0),
|
|
2418
|
+
* touchEnabled: true,
|
|
2419
|
+
* onClick: () => console.log("Button clicked!"),
|
|
2420
|
+
* onPressed: () => console.log("Button pressed!")
|
|
2421
|
+
* });
|
|
2422
|
+
* ```
|
|
2067
2423
|
*/
|
|
2068
2424
|
declare class Button {
|
|
2069
2425
|
/** The shape of the button */
|
|
@@ -2090,7 +2446,7 @@ declare class Button {
|
|
|
2090
2446
|
}
|
|
2091
2447
|
/**
|
|
2092
2448
|
* @public
|
|
2093
|
-
* @category Components
|
|
2449
|
+
* @category Components Configuration
|
|
2094
2450
|
*/
|
|
2095
2451
|
declare enum ButtonShape {
|
|
2096
2452
|
Rectangle = 0,
|
|
@@ -2098,25 +2454,56 @@ declare enum ButtonShape {
|
|
|
2098
2454
|
}
|
|
2099
2455
|
|
|
2100
2456
|
/**
|
|
2457
|
+
* TiledWrapper component configuration
|
|
2101
2458
|
* @public
|
|
2102
|
-
* @category Components
|
|
2459
|
+
* @category Components Configuration
|
|
2460
|
+
* @example
|
|
2461
|
+
* ```js
|
|
2462
|
+
* const tiledWrapper = new TiledWrapper({
|
|
2463
|
+
* tilemap: "tilemap.json",
|
|
2464
|
+
* layerToRender: "Ground"
|
|
2465
|
+
* });
|
|
2466
|
+
*
|
|
2467
|
+
* const tiledWrapper = new TiledWrapper({
|
|
2468
|
+
* tilemap: assetManager.getJson("tilemap.json"),
|
|
2469
|
+
* layerToRender: "Ground"
|
|
2470
|
+
* });
|
|
2471
|
+
* ```
|
|
2103
2472
|
*/
|
|
2104
2473
|
interface TiledWrapperOptions {
|
|
2105
|
-
tilemap: TiledTilemap;
|
|
2474
|
+
tilemap: TiledTilemap | string;
|
|
2106
2475
|
layerToRender: string;
|
|
2107
2476
|
}
|
|
2108
2477
|
/**
|
|
2478
|
+
* The TiledWrapper component wraps a Tiled map editor tilemap and handles rendering a specific layer.\
|
|
2479
|
+
* It provides an interface between Tiled's map format and the engine's tilemap rendering system.
|
|
2109
2480
|
* @public
|
|
2110
2481
|
* @category Components
|
|
2482
|
+
* @example
|
|
2483
|
+
* ```js
|
|
2484
|
+
* const tiledWrapper = new TiledWrapper({
|
|
2485
|
+
* tilemap: {
|
|
2486
|
+
* width: 10,
|
|
2487
|
+
* height: 10,
|
|
2488
|
+
* infinite: false,
|
|
2489
|
+
* layers: [],
|
|
2490
|
+
* renderorder: "right-down",
|
|
2491
|
+
* tilesets: [{ firstgid: 1 }],
|
|
2492
|
+
* tilewidth: 32,
|
|
2493
|
+
* tileheight: 32
|
|
2494
|
+
* },
|
|
2495
|
+
* layerToRender: "Ground"
|
|
2496
|
+
* });
|
|
2497
|
+
* ```
|
|
2111
2498
|
*/
|
|
2112
2499
|
declare class TiledWrapper {
|
|
2113
|
-
tilemap: TiledTilemap;
|
|
2500
|
+
tilemap: TiledTilemap | string;
|
|
2114
2501
|
layerToRender: string;
|
|
2115
2502
|
constructor(options?: Partial<TiledWrapperOptions>);
|
|
2116
2503
|
}
|
|
2117
2504
|
/**
|
|
2118
2505
|
* @public
|
|
2119
|
-
* @category Components
|
|
2506
|
+
* @category Components Configuration
|
|
2120
2507
|
*/
|
|
2121
2508
|
interface TiledTilemap {
|
|
2122
2509
|
width: number;
|
|
@@ -2133,7 +2520,7 @@ interface TiledTilemap {
|
|
|
2133
2520
|
}
|
|
2134
2521
|
/**
|
|
2135
2522
|
* @public
|
|
2136
|
-
* @category Components
|
|
2523
|
+
* @category Components Configuration
|
|
2137
2524
|
*/
|
|
2138
2525
|
interface TiledChunk {
|
|
2139
2526
|
data: number[];
|
|
@@ -2145,7 +2532,7 @@ interface TiledChunk {
|
|
|
2145
2532
|
}
|
|
2146
2533
|
/**
|
|
2147
2534
|
* @public
|
|
2148
|
-
* @category Components
|
|
2535
|
+
* @category Components Configuration
|
|
2149
2536
|
*/
|
|
2150
2537
|
interface TiledLayer {
|
|
2151
2538
|
name: string;
|
|
@@ -2168,7 +2555,7 @@ interface TiledLayer {
|
|
|
2168
2555
|
}
|
|
2169
2556
|
/**
|
|
2170
2557
|
* @public
|
|
2171
|
-
* @category Components
|
|
2558
|
+
* @category Components Configuration
|
|
2172
2559
|
*/
|
|
2173
2560
|
interface TiledObjectLayer {
|
|
2174
2561
|
draworder: string;
|
|
@@ -2184,7 +2571,7 @@ interface TiledObjectLayer {
|
|
|
2184
2571
|
}
|
|
2185
2572
|
/**
|
|
2186
2573
|
* @public
|
|
2187
|
-
* @category Components
|
|
2574
|
+
* @category Components Configuration
|
|
2188
2575
|
*/
|
|
2189
2576
|
interface TiledObject {
|
|
2190
2577
|
gid: number;
|
|
@@ -2209,7 +2596,7 @@ interface TiledObject {
|
|
|
2209
2596
|
}
|
|
2210
2597
|
/**
|
|
2211
2598
|
* @public
|
|
2212
|
-
* @category Components
|
|
2599
|
+
* @category Components Configuration
|
|
2213
2600
|
*/
|
|
2214
2601
|
interface TiledProperty {
|
|
2215
2602
|
name: string;
|
|
@@ -2218,8 +2605,17 @@ interface TiledProperty {
|
|
|
2218
2605
|
}
|
|
2219
2606
|
|
|
2220
2607
|
/**
|
|
2608
|
+
* Transform component configuration
|
|
2221
2609
|
* @public
|
|
2222
|
-
* @category Components
|
|
2610
|
+
* @category Components Configuration
|
|
2611
|
+
* @example
|
|
2612
|
+
* ```js
|
|
2613
|
+
* const transform = new Transform({
|
|
2614
|
+
* position: new Vector2(100, 100),
|
|
2615
|
+
* scale: new Vector2(2, 2),
|
|
2616
|
+
* rotation: Math.PI / 4
|
|
2617
|
+
* });
|
|
2618
|
+
* ```
|
|
2223
2619
|
*/
|
|
2224
2620
|
interface TransformOptions {
|
|
2225
2621
|
position: Vector2;
|
|
@@ -2227,8 +2623,20 @@ interface TransformOptions {
|
|
|
2227
2623
|
rotation: number;
|
|
2228
2624
|
}
|
|
2229
2625
|
/**
|
|
2626
|
+
* The Transform component defines an entity's position, scale and rotation in the game world.\
|
|
2627
|
+
* It can be nested under a parent transform to create hierarchical relationships, where child
|
|
2628
|
+
* transforms inherit and combine with their parent's transformations.\
|
|
2629
|
+
* The component provides both local and world-space values, and allows selectively ignoring parent transformations.
|
|
2230
2630
|
* @public
|
|
2231
2631
|
* @category Components
|
|
2632
|
+
* @example
|
|
2633
|
+
* ```js
|
|
2634
|
+
* const transform = new Transform({
|
|
2635
|
+
* position: new Vector2(100, 100),
|
|
2636
|
+
* scale: new Vector2(2, 2),
|
|
2637
|
+
* rotation: Math.PI / 4
|
|
2638
|
+
* });
|
|
2639
|
+
* ```
|
|
2232
2640
|
*/
|
|
2233
2641
|
declare class Transform {
|
|
2234
2642
|
/** Position relative to the zero point of the simulated world, or relative to the parent if it has one */
|
|
@@ -2237,11 +2645,17 @@ declare class Transform {
|
|
|
2237
2645
|
scale: Vector2;
|
|
2238
2646
|
/** Rotation expressed in radians */
|
|
2239
2647
|
rotation: number;
|
|
2240
|
-
/**
|
|
2648
|
+
/** If TRUE, the parent position will be ignored */
|
|
2649
|
+
ignoreParentPosition: boolean;
|
|
2650
|
+
/** If TRUE, the parent scale will be ignored */
|
|
2651
|
+
ignoreParentScale: boolean;
|
|
2652
|
+
/** If TRUE, the parent rotation will be ignored */
|
|
2653
|
+
ignoreParentRotation: boolean;
|
|
2654
|
+
/** READONLY: The real position in the simulated world. It has the same value as `position` property if there is no parent */
|
|
2241
2655
|
localPosition: Vector2;
|
|
2242
|
-
/** The real scale in the simulated world. It has the same value as `scale` property if there is no parent */
|
|
2656
|
+
/** READONLY: The real scale in the simulated world. It has the same value as `scale` property if there is no parent */
|
|
2243
2657
|
localScale: Vector2;
|
|
2244
|
-
/** The real rotation in the simulated world. It has the same value as `rotation` property if there is no parent */
|
|
2658
|
+
/** READONLY: The real rotation in the simulated world. It has the same value as `rotation` property if there is no parent */
|
|
2245
2659
|
localRotation: number;
|
|
2246
2660
|
/** @internal */
|
|
2247
2661
|
_awake: boolean;
|
|
@@ -2251,9 +2665,9 @@ declare class Transform {
|
|
|
2251
2665
|
}
|
|
2252
2666
|
|
|
2253
2667
|
/**
|
|
2254
|
-
*
|
|
2668
|
+
* BallCollider component configuration
|
|
2255
2669
|
* @public
|
|
2256
|
-
* @category Components
|
|
2670
|
+
* @category Components Configuration
|
|
2257
2671
|
* @example
|
|
2258
2672
|
* ```js
|
|
2259
2673
|
* const ballCollider = new BallCollider({
|
|
@@ -2278,7 +2692,10 @@ interface BallColliderOptions {
|
|
|
2278
2692
|
ignoreCollisionsWithLayers: string[];
|
|
2279
2693
|
}
|
|
2280
2694
|
/**
|
|
2281
|
-
*
|
|
2695
|
+
* The BallCollider component defines a circular collision shape for an entity.\
|
|
2696
|
+
* It can be used for both physics interactions and collision detection.\
|
|
2697
|
+
* The collider's size is determined by its radius, and it can be offset from the entity's position.\
|
|
2698
|
+
* Collision layers allow controlling which objects can collide with each other.
|
|
2282
2699
|
* @public
|
|
2283
2700
|
* @category Components
|
|
2284
2701
|
* @example
|
|
@@ -2309,9 +2726,9 @@ declare class BallCollider implements Collider {
|
|
|
2309
2726
|
}
|
|
2310
2727
|
|
|
2311
2728
|
/**
|
|
2312
|
-
*
|
|
2729
|
+
* BoxCollider component configuration
|
|
2313
2730
|
* @public
|
|
2314
|
-
* @category Components
|
|
2731
|
+
* @category Components Configuration
|
|
2315
2732
|
* @example
|
|
2316
2733
|
* ```js
|
|
2317
2734
|
* const boxCollider = new BoxCollider({
|
|
@@ -2342,7 +2759,10 @@ interface BoxColliderOptions {
|
|
|
2342
2759
|
ignoreCollisionsWithLayers: string[];
|
|
2343
2760
|
}
|
|
2344
2761
|
/**
|
|
2345
|
-
*
|
|
2762
|
+
* The BoxCollider component defines a rectangular collision shape for an entity.\
|
|
2763
|
+
* It can be used for both physics interactions and collision detection.\
|
|
2764
|
+
* The collider's size is determined by its width and height, and it can be offset and rotated.\
|
|
2765
|
+
* Collision layers allow controlling which objects can collide with each other.
|
|
2346
2766
|
* @public
|
|
2347
2767
|
* @category Components
|
|
2348
2768
|
* @example
|
|
@@ -2379,9 +2799,9 @@ declare class BoxCollider implements Collider {
|
|
|
2379
2799
|
}
|
|
2380
2800
|
|
|
2381
2801
|
/**
|
|
2382
|
-
*
|
|
2802
|
+
* EdgeCollider component configuration
|
|
2383
2803
|
* @public
|
|
2384
|
-
* @category Components
|
|
2804
|
+
* @category Components Configuration
|
|
2385
2805
|
* @example
|
|
2386
2806
|
* ```js
|
|
2387
2807
|
* const edgeCollider = new EdgeCollider({
|
|
@@ -2409,7 +2829,10 @@ interface EdgeColliderOptions {
|
|
|
2409
2829
|
ignoreCollisionsWithLayers: string[];
|
|
2410
2830
|
}
|
|
2411
2831
|
/**
|
|
2412
|
-
*
|
|
2832
|
+
* The EdgeCollider component defines a collision shape made up of connected line segments.\
|
|
2833
|
+
* It can be used for both physics interactions and collision detection.\
|
|
2834
|
+
* The collider's shape is determined by a series of vertices that form edges between them.\
|
|
2835
|
+
* The shape can be offset and rotated, and collision layers allow controlling which objects can collide with each other.
|
|
2413
2836
|
* @public
|
|
2414
2837
|
* @category Components
|
|
2415
2838
|
* @example
|
|
@@ -2442,9 +2865,9 @@ declare class EdgeCollider implements Collider {
|
|
|
2442
2865
|
}
|
|
2443
2866
|
|
|
2444
2867
|
/**
|
|
2445
|
-
*
|
|
2868
|
+
* PolygonCollider component configuration
|
|
2446
2869
|
* @public
|
|
2447
|
-
* @category Components
|
|
2870
|
+
* @category Components Configuration
|
|
2448
2871
|
* @example
|
|
2449
2872
|
* ```js
|
|
2450
2873
|
* const polygonCollider = new PolygonCollider({
|
|
@@ -2472,7 +2895,11 @@ interface PolygonColliderOptions {
|
|
|
2472
2895
|
ignoreCollisionsWithLayers: string[];
|
|
2473
2896
|
}
|
|
2474
2897
|
/**
|
|
2475
|
-
*
|
|
2898
|
+
* The PolygonCollider component defines a convex polygon-shaped collision area for an entity.\
|
|
2899
|
+
* It can be used for both physics interactions and collision detection.\
|
|
2900
|
+
* The collider's shape is determined by a series of vertices that form a closed convex polygon.\
|
|
2901
|
+
* Note that only convex polygons are supported - concave shapes must be broken into multiple convex polygons.\
|
|
2902
|
+
* The shape can be offset and rotated, and collision layers allow controlling which objects can collide with each other.
|
|
2476
2903
|
* @public
|
|
2477
2904
|
* @category Components
|
|
2478
2905
|
* @example
|
|
@@ -2510,7 +2937,7 @@ declare class PolygonCollider implements Collider {
|
|
|
2510
2937
|
* - **Dynamic:** This type of body is affected by gravity and velocity and can be moved by other rigid bodies.
|
|
2511
2938
|
* - **Kinematic:** This type of body is not affected by gravity and cannot be moved by other rigid bodies, but can be velocity applied.
|
|
2512
2939
|
* - **Static:** This type of body is immobile, is not affected by velocity or gravity and cannot be moved by other rigid bodies.
|
|
2513
|
-
* @category Components
|
|
2940
|
+
* @category Components Configuration
|
|
2514
2941
|
* @public
|
|
2515
2942
|
*/
|
|
2516
2943
|
declare enum RigidBodyType {
|
|
@@ -2521,7 +2948,7 @@ declare enum RigidBodyType {
|
|
|
2521
2948
|
/**
|
|
2522
2949
|
* RigidBody configuration options
|
|
2523
2950
|
* @public
|
|
2524
|
-
* @category Components
|
|
2951
|
+
* @category Components Configuration
|
|
2525
2952
|
* @example
|
|
2526
2953
|
* ```js
|
|
2527
2954
|
const rigidBody = new RigidBody({
|
|
@@ -2572,13 +2999,19 @@ interface RigidBodyOptions {
|
|
|
2572
2999
|
acceleration: Vector2;
|
|
2573
3000
|
}
|
|
2574
3001
|
/**
|
|
2575
|
-
* The RigidBody component
|
|
2576
|
-
*
|
|
2577
|
-
*
|
|
2578
|
-
* - **
|
|
2579
|
-
*
|
|
2580
|
-
*
|
|
2581
|
-
*
|
|
3002
|
+
* The RigidBody component enables physics simulation for an entity, allowing it to interact with other physics-enabled objects in the game world.\
|
|
3003
|
+
* It defines how the entity behaves under forces like gravity, collisions, and applied velocities. The component supports three types of bodies:
|
|
3004
|
+
*
|
|
3005
|
+
* - **Dynamic:** Fully physics-simulated bodies that respond to forces, collisions, gravity, and can be moved by other rigid bodies.
|
|
3006
|
+
* Best for objects that need realistic physical behavior like players, projectiles, or items.
|
|
3007
|
+
*
|
|
3008
|
+
* - **Kinematic:** Bodies that can move with applied velocities but are not affected by gravity or collisions from other bodies.
|
|
3009
|
+
* Ideal for moving platforms, enemies with predefined paths, or objects that need controlled movement without full physics simulation.
|
|
3010
|
+
* More performance efficient than Dynamic bodies.
|
|
3011
|
+
*
|
|
3012
|
+
* - **Static:** Immobile bodies that act as solid, unmovable obstacles. They don't respond to any forces or collisions.
|
|
3013
|
+
* Perfect for level geometry, walls, or any unchanging collision objects.
|
|
3014
|
+
* The most performance efficient option as they require minimal physics calculations.
|
|
2582
3015
|
* @public
|
|
2583
3016
|
* @category Components
|
|
2584
3017
|
* @example
|
|
@@ -2609,6 +3042,7 @@ declare class RigidBody {
|
|
|
2609
3042
|
/**
|
|
2610
3043
|
* The type of the rigid body to create:
|
|
2611
3044
|
* - Dynamic: This type of body is affected by gravity and velocity.
|
|
3045
|
+
* - Kinematic: This type of body is not affected by gravity and cannot be moved by other rigid bodies, but can be velocity applied.
|
|
2612
3046
|
* - Static: This type of body is immovable, is unaffected by velocity and gravity.
|
|
2613
3047
|
* @public
|
|
2614
3048
|
*/
|
|
@@ -2632,9 +3066,9 @@ declare class RigidBody {
|
|
|
2632
3066
|
}
|
|
2633
3067
|
|
|
2634
3068
|
/**
|
|
2635
|
-
*
|
|
3069
|
+
* TilemapCollider component configuration
|
|
2636
3070
|
* @public
|
|
2637
|
-
* @category Components
|
|
3071
|
+
* @category Components Configuration
|
|
2638
3072
|
* @example
|
|
2639
3073
|
* ```js
|
|
2640
3074
|
* const tilemapCollider = new TilemapCollider({
|
|
@@ -2659,8 +3093,12 @@ interface TilemapColliderOptions {
|
|
|
2659
3093
|
physics: boolean;
|
|
2660
3094
|
}
|
|
2661
3095
|
/**
|
|
2662
|
-
*
|
|
2663
|
-
*
|
|
3096
|
+
* The TilemapCollider component automatically generates collision shapes for tilemap edges.\
|
|
3097
|
+
* When composite is FALSE, it creates individual rectangle colliders for each edge tile.\
|
|
3098
|
+
* When composite is TRUE, it optimizes by generating connected line segments that follow the tilemap's outer edges.\
|
|
3099
|
+
* This is useful for efficiently handling collision detection with tilemap boundaries.\
|
|
3100
|
+
* **Limitations:** The collider shapes are generated once and cannot be modified after creation.
|
|
3101
|
+
* To update the collision shapes, you must create a new TilemapCollider instance.
|
|
2664
3102
|
* @public
|
|
2665
3103
|
* @category Components
|
|
2666
3104
|
* @example
|
|
@@ -2713,7 +3151,7 @@ interface RenderData {
|
|
|
2713
3151
|
|
|
2714
3152
|
/**
|
|
2715
3153
|
* Mask shape: Rectangle or Circumference.
|
|
2716
|
-
* @category Components
|
|
3154
|
+
* @category Components Configuration
|
|
2717
3155
|
* @public
|
|
2718
3156
|
*/
|
|
2719
3157
|
declare enum MaskShape {
|
|
@@ -2781,7 +3219,7 @@ interface SpriteRenderData extends RenderData {
|
|
|
2781
3219
|
}
|
|
2782
3220
|
/**
|
|
2783
3221
|
* Cut the image based on straight coordinates starting from the top left downward.
|
|
2784
|
-
* @category Components
|
|
3222
|
+
* @category Components Configuration
|
|
2785
3223
|
* @public
|
|
2786
3224
|
*/
|
|
2787
3225
|
interface Slice {
|
|
@@ -2797,7 +3235,7 @@ interface Slice {
|
|
|
2797
3235
|
|
|
2798
3236
|
/**
|
|
2799
3237
|
* Direction in which the text will be rendered.
|
|
2800
|
-
* @category Components
|
|
3238
|
+
* @category Components Configuration
|
|
2801
3239
|
* @public
|
|
2802
3240
|
*/
|
|
2803
3241
|
declare enum TextOrientation {
|
|
@@ -2833,8 +3271,7 @@ interface TextRenderData extends RenderData {
|
|
|
2833
3271
|
|
|
2834
3272
|
/**
|
|
2835
3273
|
* Direction in which the tilemap will be rendered.
|
|
2836
|
-
* @
|
|
2837
|
-
* @public
|
|
3274
|
+
* @internal
|
|
2838
3275
|
*/
|
|
2839
3276
|
declare enum TilemapOrientation {
|
|
2840
3277
|
Center = 0,
|
|
@@ -2844,23 +3281,8 @@ declare enum TilemapOrientation {
|
|
|
2844
3281
|
}
|
|
2845
3282
|
interface TilemapRenderData extends RenderData {
|
|
2846
3283
|
tiles: number[];
|
|
2847
|
-
tilemap:
|
|
2848
|
-
|
|
2849
|
-
tileWidth: number;
|
|
2850
|
-
tileHeight: number;
|
|
2851
|
-
height: number;
|
|
2852
|
-
realWidth: number;
|
|
2853
|
-
realHeight: number;
|
|
2854
|
-
};
|
|
2855
|
-
tileset: {
|
|
2856
|
-
image: HTMLImageElement;
|
|
2857
|
-
width: number;
|
|
2858
|
-
tileWidth: number;
|
|
2859
|
-
tileHeight: number;
|
|
2860
|
-
margin?: Vector2;
|
|
2861
|
-
spacing?: Vector2;
|
|
2862
|
-
correction?: Vector2;
|
|
2863
|
-
};
|
|
3284
|
+
tilemap: Tilemap;
|
|
3285
|
+
tileset: Tileset$1;
|
|
2864
3286
|
smooth?: boolean;
|
|
2865
3287
|
flipHorizontal?: boolean;
|
|
2866
3288
|
flipVertical?: boolean;
|
|
@@ -2871,6 +3293,23 @@ interface TilemapRenderData extends RenderData {
|
|
|
2871
3293
|
tintColor?: string;
|
|
2872
3294
|
orientation?: TilemapOrientation;
|
|
2873
3295
|
}
|
|
3296
|
+
type Tileset$1 = {
|
|
3297
|
+
image: HTMLImageElement;
|
|
3298
|
+
width: number;
|
|
3299
|
+
tileWidth: number;
|
|
3300
|
+
tileHeight: number;
|
|
3301
|
+
margin?: Vector2;
|
|
3302
|
+
spacing?: Vector2;
|
|
3303
|
+
correction?: Vector2;
|
|
3304
|
+
};
|
|
3305
|
+
type Tilemap = {
|
|
3306
|
+
width: number;
|
|
3307
|
+
tileWidth: number;
|
|
3308
|
+
tileHeight: number;
|
|
3309
|
+
height: number;
|
|
3310
|
+
realWidth: number;
|
|
3311
|
+
realHeight: number;
|
|
3312
|
+
};
|
|
2874
3313
|
|
|
2875
3314
|
interface VideoRenderData extends RenderData {
|
|
2876
3315
|
video: HTMLVideoElement;
|
|
@@ -2888,8 +3327,7 @@ interface VideoRenderData extends RenderData {
|
|
|
2888
3327
|
|
|
2889
3328
|
/**
|
|
2890
3329
|
* Default render layer
|
|
2891
|
-
* @
|
|
2892
|
-
* @category Components
|
|
3330
|
+
* @internal
|
|
2893
3331
|
*/
|
|
2894
3332
|
declare const defaultRenderLayer = "Default";
|
|
2895
3333
|
/**
|
|
@@ -2898,8 +3336,18 @@ declare const defaultRenderLayer = "Default";
|
|
|
2898
3336
|
*/
|
|
2899
3337
|
declare const debugRenderLayer = "Debug";
|
|
2900
3338
|
/**
|
|
3339
|
+
* Camera component configuration
|
|
2901
3340
|
* @public
|
|
2902
|
-
* @category Components
|
|
3341
|
+
* @category Components Configuration
|
|
3342
|
+
* @example
|
|
3343
|
+
* ```js
|
|
3344
|
+
* const camera = new Camera({
|
|
3345
|
+
* layers: ["Default", "UI", "Background"],
|
|
3346
|
+
* zoom: 1.5,
|
|
3347
|
+
* depth: 0,
|
|
3348
|
+
* debug: true
|
|
3349
|
+
* });
|
|
3350
|
+
* ```
|
|
2903
3351
|
*/
|
|
2904
3352
|
interface CameraOptions {
|
|
2905
3353
|
layers: string[];
|
|
@@ -2908,8 +3356,20 @@ interface CameraOptions {
|
|
|
2908
3356
|
debug: boolean;
|
|
2909
3357
|
}
|
|
2910
3358
|
/**
|
|
3359
|
+
* The Camera component controls what layers and objects are rendered to the screen.\
|
|
3360
|
+
* It supports multiple render layers, zoom level control, and depth ordering when using multiple cameras.\
|
|
3361
|
+
* Each camera can also optionally render debug information for development purposes.\
|
|
2911
3362
|
* @public
|
|
2912
3363
|
* @category Components
|
|
3364
|
+
* @example
|
|
3365
|
+
* ```js
|
|
3366
|
+
* const camera = new Camera({
|
|
3367
|
+
* layers: ["Default", "UI", "Background"],
|
|
3368
|
+
* zoom: 1.5,
|
|
3369
|
+
* depth: 0,
|
|
3370
|
+
* debug: true
|
|
3371
|
+
* });
|
|
3372
|
+
* ```
|
|
2913
3373
|
*/
|
|
2914
3374
|
declare class Camera {
|
|
2915
3375
|
/** Layers to be rendered by this camera. Layers are rendered in ascending order */
|
|
@@ -2926,8 +3386,18 @@ declare class Camera {
|
|
|
2926
3386
|
}
|
|
2927
3387
|
|
|
2928
3388
|
/**
|
|
3389
|
+
* LightRenderer component configuration
|
|
2929
3390
|
* @public
|
|
2930
|
-
* @category Components
|
|
3391
|
+
* @category Components Configuration
|
|
3392
|
+
* @example
|
|
3393
|
+
* ```js
|
|
3394
|
+
* const lightRenderer = new LightRenderer({
|
|
3395
|
+
* radius: 100,
|
|
3396
|
+
* smooth: true,
|
|
3397
|
+
* layer: "Default",
|
|
3398
|
+
* intensity: 0.8
|
|
3399
|
+
* });
|
|
3400
|
+
* ```
|
|
2931
3401
|
*/
|
|
2932
3402
|
interface LightRendererOptions {
|
|
2933
3403
|
radius: number;
|
|
@@ -2936,8 +3406,22 @@ interface LightRendererOptions {
|
|
|
2936
3406
|
intensity: number;
|
|
2937
3407
|
}
|
|
2938
3408
|
/**
|
|
3409
|
+
* The LightRenderer component is used to render a light effect on the screen.\
|
|
3410
|
+
* It supports a circular light source with a specified radius and intensity.\
|
|
3411
|
+
* The light can be optionally smoothed for a softer edge effect.\
|
|
3412
|
+
* This component requires a ShadowRenderer component to be present in the scene to function properly,
|
|
3413
|
+
* as it works by illuminating areas within the shadow map.\
|
|
2939
3414
|
* @public
|
|
2940
3415
|
* @category Components
|
|
3416
|
+
* @example
|
|
3417
|
+
* ```js
|
|
3418
|
+
* const lightRenderer = new LightRenderer({
|
|
3419
|
+
* radius: 100,
|
|
3420
|
+
* smooth: true,
|
|
3421
|
+
* layer: "Default",
|
|
3422
|
+
* intensity: 0.8
|
|
3423
|
+
* });
|
|
3424
|
+
* ```
|
|
2941
3425
|
*/
|
|
2942
3426
|
declare class LightRenderer {
|
|
2943
3427
|
/** Light radius */
|
|
@@ -2954,8 +3438,44 @@ declare class LightRenderer {
|
|
|
2954
3438
|
}
|
|
2955
3439
|
|
|
2956
3440
|
/**
|
|
3441
|
+
* MaskRenderer component configuration
|
|
2957
3442
|
* @public
|
|
2958
|
-
* @category Components
|
|
3443
|
+
* @category Components Configuration
|
|
3444
|
+
* @example
|
|
3445
|
+
* ```js
|
|
3446
|
+
* const maskRenderer = new MaskRenderer({
|
|
3447
|
+
* shape: MaskShape.Rectangle,
|
|
3448
|
+
* width: 32,
|
|
3449
|
+
* height: 32,
|
|
3450
|
+
* color: "#000000",
|
|
3451
|
+
* offset: new Vector2(0, 0),
|
|
3452
|
+
* rotation: 0,
|
|
3453
|
+
* opacity: 1,
|
|
3454
|
+
* layer: "Default"
|
|
3455
|
+
* });
|
|
3456
|
+
* ```
|
|
3457
|
+
* @example
|
|
3458
|
+
* ```js
|
|
3459
|
+
* const maskRenderer = new MaskRenderer({
|
|
3460
|
+
* shape: MaskShape.Circumference,
|
|
3461
|
+
* radius: 16,
|
|
3462
|
+
* color: "#000000",
|
|
3463
|
+
* offset: new Vector2(0, 0),
|
|
3464
|
+
* opacity: 1,
|
|
3465
|
+
* layer: "Default"
|
|
3466
|
+
* });
|
|
3467
|
+
* ```
|
|
3468
|
+
* @example
|
|
3469
|
+
* ```js
|
|
3470
|
+
* const maskRenderer = new MaskRenderer({
|
|
3471
|
+
* shape: MaskShape.Polygon,
|
|
3472
|
+
* vertexModel: [new Vector2(0, 0), new Vector2(32, 0), new Vector2(32, 32), new Vector2(0, 32)],
|
|
3473
|
+
* color: "#000000",
|
|
3474
|
+
* offset: new Vector2(0, 0),
|
|
3475
|
+
* opacity: 1,
|
|
3476
|
+
* layer: "Default"
|
|
3477
|
+
* });
|
|
3478
|
+
* ```
|
|
2959
3479
|
*/
|
|
2960
3480
|
interface MaskRendererOptions {
|
|
2961
3481
|
shape: MaskShape;
|
|
@@ -2970,37 +3490,46 @@ interface MaskRendererOptions {
|
|
|
2970
3490
|
layer: string;
|
|
2971
3491
|
}
|
|
2972
3492
|
/**
|
|
2973
|
-
*
|
|
3493
|
+
* The MaskRenderer component renders filled shapes like rectangles, circles, or polygons.\
|
|
3494
|
+
* It supports different shape types with configurable dimensions, colors, positioning and rotation.\
|
|
3495
|
+
* Shapes can be rendered with variable opacity and assigned to specific render layers.\
|
|
3496
|
+
* This component is useful for creating UI elements, visual effects, or masking other rendered content.
|
|
2974
3497
|
* @public
|
|
2975
3498
|
* @category Components
|
|
2976
3499
|
* @example
|
|
2977
3500
|
* ```js
|
|
2978
|
-
* maskRenderer
|
|
2979
|
-
*
|
|
2980
|
-
*
|
|
2981
|
-
*
|
|
2982
|
-
*
|
|
2983
|
-
*
|
|
2984
|
-
*
|
|
2985
|
-
*
|
|
3501
|
+
* const maskRenderer = new MaskRenderer({
|
|
3502
|
+
* shape: MaskShape.Rectangle,
|
|
3503
|
+
* width: 32,
|
|
3504
|
+
* height: 32,
|
|
3505
|
+
* color: "#000000",
|
|
3506
|
+
* offset: new Vector2(0, 0),
|
|
3507
|
+
* rotation: 0,
|
|
3508
|
+
* opacity: 1,
|
|
3509
|
+
* layer: "Default"
|
|
3510
|
+
* });
|
|
2986
3511
|
* ```
|
|
2987
3512
|
* @example
|
|
2988
3513
|
* ```js
|
|
2989
|
-
* maskRenderer
|
|
2990
|
-
*
|
|
2991
|
-
*
|
|
2992
|
-
*
|
|
2993
|
-
*
|
|
2994
|
-
*
|
|
3514
|
+
* const maskRenderer = new MaskRenderer({
|
|
3515
|
+
* shape: MaskShape.Circumference,
|
|
3516
|
+
* radius: 16,
|
|
3517
|
+
* color: "#000000",
|
|
3518
|
+
* offset: new Vector2(0, 0),
|
|
3519
|
+
* opacity: 1,
|
|
3520
|
+
* layer: "Default"
|
|
3521
|
+
* });
|
|
2995
3522
|
* ```
|
|
2996
3523
|
* @example
|
|
2997
3524
|
* ```js
|
|
2998
|
-
* maskRenderer
|
|
2999
|
-
*
|
|
3000
|
-
*
|
|
3001
|
-
*
|
|
3002
|
-
*
|
|
3003
|
-
*
|
|
3525
|
+
* const maskRenderer = new MaskRenderer({
|
|
3526
|
+
* shape: MaskShape.Polygon,
|
|
3527
|
+
* vertexModel: [new Vector2(0, 0), new Vector2(32, 0), new Vector2(32, 32), new Vector2(0, 32)],
|
|
3528
|
+
* color: "#000000",
|
|
3529
|
+
* offset: new Vector2(0, 0),
|
|
3530
|
+
* opacity: 1,
|
|
3531
|
+
* layer: "Default"
|
|
3532
|
+
* });
|
|
3004
3533
|
* ```
|
|
3005
3534
|
*/
|
|
3006
3535
|
declare class MaskRenderer {
|
|
@@ -3030,8 +3559,19 @@ declare class MaskRenderer {
|
|
|
3030
3559
|
}
|
|
3031
3560
|
|
|
3032
3561
|
/**
|
|
3562
|
+
* ShadowRenderer component configuration
|
|
3033
3563
|
* @public
|
|
3034
|
-
* @category Components
|
|
3564
|
+
* @category Components Configuration
|
|
3565
|
+
* @example
|
|
3566
|
+
* ```js
|
|
3567
|
+
* const shadowRenderer = new ShadowRenderer({
|
|
3568
|
+
* width: 100,
|
|
3569
|
+
* height: 50,
|
|
3570
|
+
* color: "#000000",
|
|
3571
|
+
* opacity: 0.5,
|
|
3572
|
+
* layer: "Default"
|
|
3573
|
+
* });
|
|
3574
|
+
* ```
|
|
3035
3575
|
*/
|
|
3036
3576
|
interface ShadowRendererOptions {
|
|
3037
3577
|
width: number;
|
|
@@ -3041,8 +3581,22 @@ interface ShadowRendererOptions {
|
|
|
3041
3581
|
layer: string;
|
|
3042
3582
|
}
|
|
3043
3583
|
/**
|
|
3584
|
+
* The ShadowRenderer component is used to render a shadow effect on the screen.\
|
|
3585
|
+
* It supports a rectangular shadow with configurable width, height, color, opacity, and render layer.\
|
|
3586
|
+
* This component works in conjunction with LightRenderer components in the scene - the shadow will
|
|
3587
|
+
* block and be affected by any lights that intersect with it.\
|
|
3044
3588
|
* @public
|
|
3045
3589
|
* @category Components
|
|
3590
|
+
* @example
|
|
3591
|
+
* ```js
|
|
3592
|
+
* const shadowRenderer = new ShadowRenderer({
|
|
3593
|
+
* width: 100,
|
|
3594
|
+
* height: 50,
|
|
3595
|
+
* color: "#000000",
|
|
3596
|
+
* opacity: 0.5,
|
|
3597
|
+
* layer: "Default"
|
|
3598
|
+
* });
|
|
3599
|
+
* ```
|
|
3046
3600
|
*/
|
|
3047
3601
|
declare class ShadowRenderer {
|
|
3048
3602
|
/** Shadow width */
|
|
@@ -3063,11 +3617,33 @@ declare class ShadowRenderer {
|
|
|
3063
3617
|
}
|
|
3064
3618
|
|
|
3065
3619
|
/**
|
|
3620
|
+
* SpriteRenderer component configuration
|
|
3066
3621
|
* @public
|
|
3067
|
-
* @category Components
|
|
3622
|
+
* @category Components Configuration
|
|
3623
|
+
* @example
|
|
3624
|
+
* ```js
|
|
3625
|
+
* const spriteRenderer = new SpriteRenderer({
|
|
3626
|
+
* image: this.assetManager.getImage("image.png"),
|
|
3627
|
+
* width: 1920,
|
|
3628
|
+
* height: 1080,
|
|
3629
|
+
* offset: new Vector2(0, 0),
|
|
3630
|
+
* flipHorizontally: false,
|
|
3631
|
+
* flipVertically: false,
|
|
3632
|
+
* rotation: 0,
|
|
3633
|
+
* opacity: 1,
|
|
3634
|
+
* maskColor: "#FF0000",
|
|
3635
|
+
* maskColorMix: 0,
|
|
3636
|
+
* tintColor: "#00FF00",
|
|
3637
|
+
* layer: "Default",
|
|
3638
|
+
* slice: {x: 0, y: 0, width: 1920, height: 1080},
|
|
3639
|
+
* scale: new Vector2(1, 1),
|
|
3640
|
+
* tiled: new Vector2(1, 1),
|
|
3641
|
+
* smooth: false
|
|
3642
|
+
* });
|
|
3643
|
+
* ```
|
|
3068
3644
|
*/
|
|
3069
3645
|
interface SpriteRendererOptions {
|
|
3070
|
-
image: HTMLImageElement;
|
|
3646
|
+
image: HTMLImageElement | string;
|
|
3071
3647
|
layer: string;
|
|
3072
3648
|
slice: Slice;
|
|
3073
3649
|
smooth: boolean;
|
|
@@ -3085,33 +3661,39 @@ interface SpriteRendererOptions {
|
|
|
3085
3661
|
tiled: Vector2;
|
|
3086
3662
|
}
|
|
3087
3663
|
/**
|
|
3664
|
+
* The SpriteRenderer component renders 2D images (sprites) to the screen.\
|
|
3665
|
+
* It supports features like image slicing, scaling, rotation, flipping, opacity, color masking and tinting.\
|
|
3666
|
+
* Images can be rendered with custom dimensions, positioned with offsets, and even tiled across an area.\
|
|
3667
|
+
* The component allows control over pixel smoothing and can be assigned to specific render layers.
|
|
3088
3668
|
* @public
|
|
3089
3669
|
* @category Components
|
|
3090
3670
|
* @example
|
|
3091
3671
|
* ```js
|
|
3092
|
-
* spriteRenderer
|
|
3093
|
-
*
|
|
3094
|
-
*
|
|
3095
|
-
*
|
|
3096
|
-
*
|
|
3097
|
-
*
|
|
3098
|
-
*
|
|
3099
|
-
*
|
|
3100
|
-
*
|
|
3101
|
-
*
|
|
3102
|
-
*
|
|
3103
|
-
*
|
|
3104
|
-
*
|
|
3105
|
-
*
|
|
3106
|
-
*
|
|
3107
|
-
*
|
|
3672
|
+
* const spriteRenderer = new SpriteRenderer({
|
|
3673
|
+
* image: this.assetManager.getImage("image.png"),
|
|
3674
|
+
* width: 1920,
|
|
3675
|
+
* height: 1080,
|
|
3676
|
+
* offset: new Vector2(0, 0),
|
|
3677
|
+
* flipHorizontally: false,
|
|
3678
|
+
* flipVertically: false,
|
|
3679
|
+
* rotation: 0,
|
|
3680
|
+
* opacity: 1,
|
|
3681
|
+
* maskColor: "#FF0000",
|
|
3682
|
+
* maskColorMix: 0,
|
|
3683
|
+
* tintColor: "#00FF00",
|
|
3684
|
+
* layer: "Default",
|
|
3685
|
+
* slice: {x: 0, y: 0, width: 1920, height: 1080},
|
|
3686
|
+
* scale: new Vector2(1, 1),
|
|
3687
|
+
* tiled: new Vector2(1, 1),
|
|
3688
|
+
* smooth: false
|
|
3689
|
+
* });
|
|
3108
3690
|
* ```
|
|
3109
3691
|
*/
|
|
3110
3692
|
declare class SpriteRenderer {
|
|
3111
3693
|
/** The render layer */
|
|
3112
3694
|
layer: string;
|
|
3113
3695
|
/** The image to render */
|
|
3114
|
-
image: HTMLImageElement;
|
|
3696
|
+
image: HTMLImageElement | string;
|
|
3115
3697
|
/** Cut the image based on straight coordinates starting from the top left downward */
|
|
3116
3698
|
slice?: Slice;
|
|
3117
3699
|
/** TRUE for smooth pixels (not recommended for pixel art) */
|
|
@@ -3154,8 +3736,40 @@ declare const defaultTextureAtlasOptions: {
|
|
|
3154
3736
|
spacing: number;
|
|
3155
3737
|
};
|
|
3156
3738
|
/**
|
|
3739
|
+
* TextRenderer component configuration
|
|
3157
3740
|
* @public
|
|
3158
|
-
* @category Components
|
|
3741
|
+
* @category Components Configuration
|
|
3742
|
+
* @example
|
|
3743
|
+
* ```js
|
|
3744
|
+
* const textRenderer = new TextRenderer({
|
|
3745
|
+
* text: "Hello World!",
|
|
3746
|
+
* color: "#FFFFFF",
|
|
3747
|
+
* fontSize: 24,
|
|
3748
|
+
* width: 1920,
|
|
3749
|
+
* height: 32,
|
|
3750
|
+
* opacity: 1,
|
|
3751
|
+
* layer: "TextLayer",
|
|
3752
|
+
* orientation: TextOrientation.RightCenter,
|
|
3753
|
+
* shadow: {
|
|
3754
|
+
* color: "#00FF00",
|
|
3755
|
+
* offset: new Vector2(3, -3),
|
|
3756
|
+
* opacity: 0.5,
|
|
3757
|
+
* },
|
|
3758
|
+
* textureAtlas: {
|
|
3759
|
+
* charRanges: [32, 126, 161, 255, 0x3040, 0x309f],
|
|
3760
|
+
* fontSize: 64,
|
|
3761
|
+
* spacing: 4,
|
|
3762
|
+
* },
|
|
3763
|
+
* font: "Arial",
|
|
3764
|
+
* flipHorizontally: false,
|
|
3765
|
+
* flipVertically: false,
|
|
3766
|
+
* letterSpacing: 0,
|
|
3767
|
+
* lineHeight: 24,
|
|
3768
|
+
* offset: new Vector2(0, 0),
|
|
3769
|
+
* rotation: 0,
|
|
3770
|
+
* smooth: false,
|
|
3771
|
+
* });
|
|
3772
|
+
* ```
|
|
3159
3773
|
*/
|
|
3160
3774
|
interface TextRendererOptions {
|
|
3161
3775
|
/** The text color */
|
|
@@ -3212,7 +3826,13 @@ interface TextRendererOptions {
|
|
|
3212
3826
|
width: number;
|
|
3213
3827
|
}
|
|
3214
3828
|
/**
|
|
3215
|
-
* The TextRenderer component
|
|
3829
|
+
* The TextRenderer component renders text to the screen with extensive customization options.\
|
|
3830
|
+
* It supports both web-safe and imported fonts, but works optimally with bitmap fonts.\
|
|
3831
|
+
* Under the hood, it generates a texture atlas containing all the characters needed for rendering.\
|
|
3832
|
+
* The atlas generation can be configured with custom character ranges, font sizes, and spacing.\
|
|
3833
|
+
* Text can be customized with font families, colors, sizing, orientation, shadows, letter spacing,\
|
|
3834
|
+
* line height, opacity, smoothing, and positioning. The component allows text to be rotated,\
|
|
3835
|
+
* flipped, and assigned to specific render layers.
|
|
3216
3836
|
* @public
|
|
3217
3837
|
* @category Components
|
|
3218
3838
|
* @example
|
|
@@ -3318,8 +3938,34 @@ declare class TextRenderer {
|
|
|
3318
3938
|
}
|
|
3319
3939
|
|
|
3320
3940
|
/**
|
|
3941
|
+
* TilemapRenderer component configuration
|
|
3321
3942
|
* @public
|
|
3322
|
-
* @category Components
|
|
3943
|
+
* @category Components Configuration
|
|
3944
|
+
* @example
|
|
3945
|
+
* ```js
|
|
3946
|
+
* const tilemapRenderer = new TilemapRenderer({
|
|
3947
|
+
* layer: "Default",
|
|
3948
|
+
* tileset: {
|
|
3949
|
+
* image: this.assetManager.getImage("tileset.png"),
|
|
3950
|
+
* width: 10,
|
|
3951
|
+
* tileWidth: 32,
|
|
3952
|
+
* tileHeight: 32,
|
|
3953
|
+
* margin: new Vector2(0, 0),
|
|
3954
|
+
* spacing: new Vector2(0, 0)
|
|
3955
|
+
* },
|
|
3956
|
+
* data: [1, 2, 3, 4],
|
|
3957
|
+
* chunks: [],
|
|
3958
|
+
* width: 2,
|
|
3959
|
+
* height: 2,
|
|
3960
|
+
* tileWidth: 32,
|
|
3961
|
+
* tileHeight: 32,
|
|
3962
|
+
* tintColor: "#FFFFFF",
|
|
3963
|
+
* maskColor: "#FF0000",
|
|
3964
|
+
* maskColorMix: 0,
|
|
3965
|
+
* opacity: 1,
|
|
3966
|
+
* smooth: false
|
|
3967
|
+
* });
|
|
3968
|
+
* ```
|
|
3323
3969
|
*/
|
|
3324
3970
|
interface TilemapRendererOptions {
|
|
3325
3971
|
layer: string;
|
|
@@ -3337,9 +3983,38 @@ interface TilemapRendererOptions {
|
|
|
3337
3983
|
smooth: boolean;
|
|
3338
3984
|
}
|
|
3339
3985
|
/**
|
|
3340
|
-
* The TilemapRenderer component
|
|
3986
|
+
* The TilemapRenderer component renders 2D tile-based maps to the screen.\
|
|
3987
|
+
* It uses a tileset image as a source for individual tiles, which are arranged according to a provided array of tile IDs.\
|
|
3988
|
+
* The component supports features like tinting, masking, opacity control, and custom tile dimensions.\
|
|
3989
|
+
* Maps can be rendered in chunks for improved performance with large tilemaps, and tiles can be assigned to specific render layers.\
|
|
3990
|
+
* Each tile is referenced by an ID, with 0 representing empty space.
|
|
3341
3991
|
* @public
|
|
3342
3992
|
* @category Components
|
|
3993
|
+
* @example
|
|
3994
|
+
* ```js
|
|
3995
|
+
* const tilemapRenderer = new TilemapRenderer({
|
|
3996
|
+
* layer: "Default",
|
|
3997
|
+
* tileset: {
|
|
3998
|
+
* image: this.assetManager.getImage("tileset.png"),
|
|
3999
|
+
* width: 10,
|
|
4000
|
+
* tileWidth: 32,
|
|
4001
|
+
* tileHeight: 32,
|
|
4002
|
+
* margin: new Vector2(0, 0),
|
|
4003
|
+
* spacing: new Vector2(0, 0)
|
|
4004
|
+
* },
|
|
4005
|
+
* data: [1, 2, 3, 4],
|
|
4006
|
+
* chunks: [],
|
|
4007
|
+
* width: 2,
|
|
4008
|
+
* height: 2,
|
|
4009
|
+
* tileWidth: 32,
|
|
4010
|
+
* tileHeight: 32,
|
|
4011
|
+
* tintColor: "#FFFFFF",
|
|
4012
|
+
* maskColor: "#FF0000",
|
|
4013
|
+
* maskColorMix: 0,
|
|
4014
|
+
* opacity: 1,
|
|
4015
|
+
* smooth: false
|
|
4016
|
+
* });
|
|
4017
|
+
* ```
|
|
3343
4018
|
*/
|
|
3344
4019
|
declare class TilemapRenderer {
|
|
3345
4020
|
/** The render layer */
|
|
@@ -3375,13 +4050,16 @@ declare class TilemapRenderer {
|
|
|
3375
4050
|
constructor(options?: Partial<TilemapRendererOptions>);
|
|
3376
4051
|
}
|
|
3377
4052
|
/**
|
|
3378
|
-
* Tileset configuration
|
|
4053
|
+
* The Tileset configuration defines the properties of a tileset used by the TilemapRenderer.\
|
|
4054
|
+
* It specifies the source image containing the tiles, the dimensions of the tileset and individual tiles,\
|
|
4055
|
+
* and optional margin and spacing between tiles. This configuration is essential for properly\
|
|
4056
|
+
* slicing and rendering tiles from the tileset image.
|
|
3379
4057
|
* @public
|
|
3380
|
-
* @category Components
|
|
4058
|
+
* @category Components Configuration
|
|
3381
4059
|
*/
|
|
3382
4060
|
type Tileset = {
|
|
3383
4061
|
/** The tileset image element */
|
|
3384
|
-
image: HTMLImageElement;
|
|
4062
|
+
image: HTMLImageElement | string;
|
|
3385
4063
|
width: number;
|
|
3386
4064
|
tileWidth: number;
|
|
3387
4065
|
tileHeight: number;
|
|
@@ -3393,7 +4071,7 @@ type Tileset = {
|
|
|
3393
4071
|
/**
|
|
3394
4072
|
* Chunk of tile data
|
|
3395
4073
|
* @public
|
|
3396
|
-
* @category Components
|
|
4074
|
+
* @category Components Configuration
|
|
3397
4075
|
*/
|
|
3398
4076
|
type Chunk = {
|
|
3399
4077
|
/** Array of tiles. ID 0 (zero) represents empty space.*/
|
|
@@ -3407,8 +4085,30 @@ type Chunk = {
|
|
|
3407
4085
|
};
|
|
3408
4086
|
|
|
3409
4087
|
/**
|
|
4088
|
+
* VideoRenderer component configuration
|
|
3410
4089
|
* @public
|
|
3411
|
-
* @category Components
|
|
4090
|
+
* @category Components Configuration
|
|
4091
|
+
* @example
|
|
4092
|
+
* ```js
|
|
4093
|
+
* const videoRenderer = new VideoRenderer({
|
|
4094
|
+
* video: this.assetManager.getVideo("video.mp4"),
|
|
4095
|
+
* width: 1920,
|
|
4096
|
+
* height: 1080,
|
|
4097
|
+
* offset: new Vector2(0, 0),
|
|
4098
|
+
* flipHorizontally: false,
|
|
4099
|
+
* flipVertically: false,
|
|
4100
|
+
* rotation: 0,
|
|
4101
|
+
* opacity: 1,
|
|
4102
|
+
* maskColor: "#FF0000",
|
|
4103
|
+
* maskColorMix: 0,
|
|
4104
|
+
* tintColor: "#00FF00",
|
|
4105
|
+
* layer: "Default",
|
|
4106
|
+
* slice: {x: 0, y: 0, width: 1920, height: 1080},
|
|
4107
|
+
* volume: 1,
|
|
4108
|
+
* loop: false,
|
|
4109
|
+
* fixedToTimeScale: false
|
|
4110
|
+
* });
|
|
4111
|
+
* ```
|
|
3412
4112
|
*/
|
|
3413
4113
|
interface VideoRendererOptions {
|
|
3414
4114
|
action: "play" | "pause" | "stop";
|
|
@@ -3425,32 +4125,38 @@ interface VideoRendererOptions {
|
|
|
3425
4125
|
rotation: number;
|
|
3426
4126
|
slice: Slice;
|
|
3427
4127
|
tintColor: string;
|
|
3428
|
-
video: HTMLVideoElement;
|
|
4128
|
+
video: HTMLVideoElement | string;
|
|
3429
4129
|
volume: number;
|
|
3430
4130
|
width: number;
|
|
3431
4131
|
}
|
|
3432
4132
|
/**
|
|
3433
|
-
* The VideoRenderer component
|
|
3434
|
-
*
|
|
4133
|
+
* The VideoRenderer component renders video content to the screen.\
|
|
4134
|
+
* It supports features like video playback control, scaling, rotation, flipping, opacity, color masking and tinting.\
|
|
4135
|
+
* Videos can be rendered with custom dimensions, positioned with offsets, and sliced to show specific regions.\
|
|
4136
|
+
* The component provides control over looping, volume, time scaling, and can be assigned to specific render layers.\
|
|
4137
|
+
* Videos can be paused, played, and stopped programmatically.
|
|
3435
4138
|
* @public
|
|
3436
4139
|
* @category Components
|
|
3437
4140
|
* @example
|
|
3438
4141
|
* ```js
|
|
3439
|
-
* videoRenderer
|
|
3440
|
-
*
|
|
3441
|
-
*
|
|
3442
|
-
*
|
|
3443
|
-
*
|
|
3444
|
-
*
|
|
3445
|
-
*
|
|
3446
|
-
*
|
|
3447
|
-
*
|
|
3448
|
-
*
|
|
3449
|
-
*
|
|
3450
|
-
*
|
|
3451
|
-
*
|
|
3452
|
-
*
|
|
3453
|
-
*
|
|
4142
|
+
* const videoRenderer = new VideoRenderer({
|
|
4143
|
+
* video: this.assetManager.getVideo("video.mp4"),
|
|
4144
|
+
* width: 1920,
|
|
4145
|
+
* height: 1080,
|
|
4146
|
+
* offset: new Vector2(0, 0),
|
|
4147
|
+
* flipHorizontally: false,
|
|
4148
|
+
* flipVertically: false,
|
|
4149
|
+
* rotation: 0,
|
|
4150
|
+
* opacity: 1,
|
|
4151
|
+
* maskColor: "#FF0000",
|
|
4152
|
+
* maskColorMix: 0,
|
|
4153
|
+
* tintColor: "#00FF00",
|
|
4154
|
+
* layer: "Default",
|
|
4155
|
+
* slice: {x: 0, y: 0, width: 1920, height: 1080},
|
|
4156
|
+
* volume: 1,
|
|
4157
|
+
* loop: false,
|
|
4158
|
+
* fixedToTimeScale: false
|
|
4159
|
+
* });
|
|
3454
4160
|
* videoRenderer.play();
|
|
3455
4161
|
* ```
|
|
3456
4162
|
*/
|
|
@@ -3486,7 +4192,7 @@ declare class VideoRenderer {
|
|
|
3486
4192
|
/** Define a color for tinting the video */
|
|
3487
4193
|
tintColor: string;
|
|
3488
4194
|
/**The video element to render */
|
|
3489
|
-
video: HTMLVideoElement;
|
|
4195
|
+
video: HTMLVideoElement | string;
|
|
3490
4196
|
/** The volume of the video (between 1 and 0) */
|
|
3491
4197
|
volume: number;
|
|
3492
4198
|
/** Overwrite the original video width */
|
|
@@ -3511,7 +4217,8 @@ declare class VideoRenderer {
|
|
|
3511
4217
|
}
|
|
3512
4218
|
|
|
3513
4219
|
/**
|
|
3514
|
-
*
|
|
4220
|
+
* Represents a connected gamepad controller and provides access to its button states and analog axes values.
|
|
4221
|
+
* Tracks digital button presses, analog stick positions, and d-pad inputs in a normalized format.
|
|
3515
4222
|
* @public
|
|
3516
4223
|
* @category Input
|
|
3517
4224
|
* @example
|
|
@@ -3519,11 +4226,11 @@ declare class VideoRenderer {
|
|
|
3519
4226
|
* const gamepad = this.inputManager.gamepads[0];
|
|
3520
4227
|
*
|
|
3521
4228
|
* if (gamepad.dpadAxes.x > 1) {
|
|
3522
|
-
* // if the
|
|
4229
|
+
* // if the d-pad x-axis is pressed to the right, do some action
|
|
3523
4230
|
* }
|
|
3524
4231
|
*
|
|
3525
4232
|
* if (gamepad.rightFace) {
|
|
3526
|
-
* // if the right face button is pressed, do some action
|
|
4233
|
+
* // if the right face button is pressed (Dual Shock: Square. Xbox: X. Nintendo: Y), do some action
|
|
3527
4234
|
* }
|
|
3528
4235
|
* ```
|
|
3529
4236
|
*/
|
|
@@ -3669,8 +4376,9 @@ type VibrationInput = {
|
|
|
3669
4376
|
};
|
|
3670
4377
|
|
|
3671
4378
|
/**
|
|
3672
|
-
*
|
|
3673
|
-
*
|
|
4379
|
+
* Tracks and provides access to keyboard input state from the previous frame.
|
|
4380
|
+
* Uses the standardized `code` property from JavaScript KeyboardEvents to identify keys.
|
|
4381
|
+
* Provides methods to check if individual keys or combinations of keys are pressed.
|
|
3674
4382
|
* @see [KeyboardEvent: code property](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code)
|
|
3675
4383
|
* @public
|
|
3676
4384
|
* @category Input
|
|
@@ -3747,7 +4455,8 @@ declare class Keyboard {
|
|
|
3747
4455
|
}
|
|
3748
4456
|
|
|
3749
4457
|
/**
|
|
3750
|
-
*
|
|
4458
|
+
* Stores the mouse state from the previous frame, including button states, cursor position,
|
|
4459
|
+
* movement status, and scroll wheel information
|
|
3751
4460
|
* @public
|
|
3752
4461
|
* @category Input
|
|
3753
4462
|
* @example
|
|
@@ -3787,7 +4496,7 @@ declare class Mouse {
|
|
|
3787
4496
|
}
|
|
3788
4497
|
|
|
3789
4498
|
/**
|
|
3790
|
-
*
|
|
4499
|
+
* Represents a single touch or pointer interaction with the screen, including position and size information
|
|
3791
4500
|
* @public
|
|
3792
4501
|
* @category Input
|
|
3793
4502
|
*/
|
|
@@ -3798,7 +4507,8 @@ interface TouchInteraction {
|
|
|
3798
4507
|
radius: Vector2;
|
|
3799
4508
|
}
|
|
3800
4509
|
/**
|
|
3801
|
-
*
|
|
4510
|
+
* Tracks and provides access to touch screen input state from the previous frame. Supports multi-touch
|
|
4511
|
+
* by storing an array of active touch interactions, each containing position and size information.
|
|
3802
4512
|
* @public
|
|
3803
4513
|
* @category Input
|
|
3804
4514
|
* @example
|
|
@@ -3822,7 +4532,52 @@ declare class TouchScreen {
|
|
|
3822
4532
|
}
|
|
3823
4533
|
|
|
3824
4534
|
/**
|
|
3825
|
-
* Manages
|
|
4535
|
+
* Manages input sources including keyboard, mouse, gamepad and touch screen interactions.\
|
|
4536
|
+
* Provides methods to check key states, mouse position/buttons, gamepad inputs and touch events.
|
|
4537
|
+
* @example
|
|
4538
|
+
* ```typescript
|
|
4539
|
+
* // Keyboard input
|
|
4540
|
+
* if (inputManager.keyboard.isPressed("Space")) {
|
|
4541
|
+
* // Jump action
|
|
4542
|
+
* }
|
|
4543
|
+
*
|
|
4544
|
+
* // Multiple key checks
|
|
4545
|
+
* if (inputManager.keyboard.orPressed(["Enter", "Space"])) {
|
|
4546
|
+
* // Action for either key pressed
|
|
4547
|
+
* }
|
|
4548
|
+
*
|
|
4549
|
+
* if (inputManager.keyboard.andPressed(["ControlLeft", "KeyC"])) {
|
|
4550
|
+
* // Action for both keys pressed together
|
|
4551
|
+
* }
|
|
4552
|
+
*
|
|
4553
|
+
* // Mouse input
|
|
4554
|
+
* const mousePos = inputManager.mouse.positionInViewport;
|
|
4555
|
+
* if (inputManager.mouse.leftButtonPressed) {
|
|
4556
|
+
* // Shoot action
|
|
4557
|
+
* }
|
|
4558
|
+
*
|
|
4559
|
+
* // Mouse wheel scrolling
|
|
4560
|
+
* const scrollAmount = inputManager.mouse.wheelScroll;
|
|
4561
|
+
*
|
|
4562
|
+
* // Gamepad input
|
|
4563
|
+
* const gamepad = inputManager.gamepads[0];
|
|
4564
|
+
* if (gamepad?.bottomFace) {
|
|
4565
|
+
* // Bottom face button pressed (A on Xbox, B on Nintendo, X on PlayStation)
|
|
4566
|
+
* }
|
|
4567
|
+
*
|
|
4568
|
+
* // Gamepad stick movement
|
|
4569
|
+
* const leftStickPos = gamepad?.leftStickAxes;
|
|
4570
|
+
* const rightStickPos = gamepad?.rightStickAxes;
|
|
4571
|
+
*
|
|
4572
|
+
* // Gamepad vibration
|
|
4573
|
+
* gamepad?.vibrate(200, 0.5, 0.5);
|
|
4574
|
+
*
|
|
4575
|
+
* // Touch input
|
|
4576
|
+
* if (inputManager.touchScreen.touching) {
|
|
4577
|
+
* const touch = inputManager.touchScreen.interactions[0];
|
|
4578
|
+
* // Handle touch at touch.positionInViewport
|
|
4579
|
+
* }
|
|
4580
|
+
* ```
|
|
3826
4581
|
* @public
|
|
3827
4582
|
* @category Managers
|
|
3828
4583
|
*/
|
|
@@ -3839,8 +4594,15 @@ declare class InputManager {
|
|
|
3839
4594
|
}
|
|
3840
4595
|
|
|
3841
4596
|
/**
|
|
3842
|
-
* Abstract class
|
|
3843
|
-
*
|
|
4597
|
+
* Abstract base class for creating game systems with commonly needed dependencies injected.\
|
|
4598
|
+
* Provides access to the following core managers and services:\
|
|
4599
|
+
* - EntityManager: For managing game entities and components\
|
|
4600
|
+
* - AssetManager: For loading and managing game resources\
|
|
4601
|
+
* - SceneManager: For controlling scene transitions and state\
|
|
4602
|
+
* - TimeManager: For handling game timing and delta time\
|
|
4603
|
+
* - InputManager: For processing keyboard, mouse and touch input\
|
|
4604
|
+
* - CollisionRepository: For physics and collision detection\
|
|
4605
|
+
* - GameConfig: For accessing game configuration settings
|
|
3844
4606
|
* @public
|
|
3845
4607
|
* @category Core
|
|
3846
4608
|
* @example
|
|
@@ -3868,7 +4630,9 @@ declare abstract class GameSystem implements System {
|
|
|
3868
4630
|
}
|
|
3869
4631
|
|
|
3870
4632
|
/**
|
|
3871
|
-
* Decorator to indicate that the target system will run in the game logic loop
|
|
4633
|
+
* Decorator to indicate that the target system will run in the game logic loop.\
|
|
4634
|
+
* Game logic systems handle core gameplay mechanics, AI behavior, input processing,\
|
|
4635
|
+
* and other non-physics, non-rendering game state updates that occur each frame.
|
|
3872
4636
|
* @public
|
|
3873
4637
|
* @category Decorators
|
|
3874
4638
|
* @example
|
|
@@ -3880,7 +4644,9 @@ declare abstract class GameSystem implements System {
|
|
|
3880
4644
|
*/
|
|
3881
4645
|
declare function gameLogicSystem(): (target: SystemType) => void;
|
|
3882
4646
|
/**
|
|
3883
|
-
* Decorator to indicate that the target system will run in the physics loop
|
|
4647
|
+
* Decorator to indicate that the target system will run in the physics loop.\
|
|
4648
|
+
* Physics systems handle physics calculations, collisions, and other physics-related updates.\
|
|
4649
|
+
* They typically run at a lower frequency than game logic systems to ensure accurate physics simulations.
|
|
3884
4650
|
* @public
|
|
3885
4651
|
* @category Decorators
|
|
3886
4652
|
* @example
|
|
@@ -3892,7 +4658,10 @@ declare function gameLogicSystem(): (target: SystemType) => void;
|
|
|
3892
4658
|
*/
|
|
3893
4659
|
declare function gamePhysicsSystem(): (target: SystemType) => void;
|
|
3894
4660
|
/**
|
|
3895
|
-
* Decorator to indicate that the target system will be executed at the begining of the render loop
|
|
4661
|
+
* Decorator to indicate that the target system will be executed at the begining of the render loop.\
|
|
4662
|
+
* Pre-render systems handle tasks that need to be completed before the final rendering step.\
|
|
4663
|
+
* They are useful for tasks like sorting sprites, updating UI elements, and positioning the camera before rendering,
|
|
4664
|
+
* along with other preparatory operations.
|
|
3896
4665
|
* @public
|
|
3897
4666
|
* @category Decorators
|
|
3898
4667
|
* @example
|
|
@@ -3905,7 +4674,9 @@ declare function gamePhysicsSystem(): (target: SystemType) => void;
|
|
|
3905
4674
|
declare function gamePreRenderSystem(): (target: SystemType) => void;
|
|
3906
4675
|
|
|
3907
4676
|
/**
|
|
3908
|
-
* Applies a decorator manually
|
|
4677
|
+
* Applies a decorator manually to a target (class, property, or constructor parameter).\
|
|
4678
|
+
* This utility function simplifies the process of programmatically applying decorators without using the @ syntax.\
|
|
4679
|
+
* This is primarily useful in JavaScript where decorator syntax is not yet standardized.
|
|
3909
4680
|
* @param decorator The decorator function to be applied.
|
|
3910
4681
|
* @param target The target to which the decorator is applied (class, prototype, or constructor argument).
|
|
3911
4682
|
* @param propertyKey The property name or constructor argument index (optional).
|
|
@@ -3935,9 +4706,26 @@ declare function gamePreRenderSystem(): (target: SystemType) => void;
|
|
|
3935
4706
|
declare function decorate(decorator: (...args: any[]) => any, target: any, propertyKey?: string | symbol | number): void;
|
|
3936
4707
|
|
|
3937
4708
|
/**
|
|
3938
|
-
*
|
|
4709
|
+
* Configuration options for playing sound effects with the playSfx function.
|
|
4710
|
+
* Allows specifying the audio source to play, optional volume level (0-1),
|
|
4711
|
+
* and whether the sound should loop continuously.
|
|
3939
4712
|
* @public
|
|
3940
4713
|
* @category Audio
|
|
4714
|
+
* @example
|
|
4715
|
+
* ```javascript
|
|
4716
|
+
* const audioSource = this.assetManager.getAudio("audio/sfx/coin.ogg");
|
|
4717
|
+
* playSfx({ audioSource });
|
|
4718
|
+
* ```
|
|
4719
|
+
* @example
|
|
4720
|
+
* ```javascript
|
|
4721
|
+
* const audioSource = this.assetManager.getAudio("audio/sfx/coin.ogg");
|
|
4722
|
+
* playSfx({ audioSource, volume: 0.5 });
|
|
4723
|
+
* ```
|
|
4724
|
+
* @example
|
|
4725
|
+
* ```javascript
|
|
4726
|
+
* const audioSource = this.assetManager.getAudio("audio/sfx/coin.ogg");
|
|
4727
|
+
* playSfx({ audioSource, loop: true });
|
|
4728
|
+
* ```
|
|
3941
4729
|
*/
|
|
3942
4730
|
interface PlaySfxOptions {
|
|
3943
4731
|
audioSource: HTMLAudioElement;
|
|
@@ -3945,8 +4733,9 @@ interface PlaySfxOptions {
|
|
|
3945
4733
|
loop?: boolean;
|
|
3946
4734
|
}
|
|
3947
4735
|
/**
|
|
3948
|
-
*
|
|
3949
|
-
*
|
|
4736
|
+
* Plays a sound effect from the beginning, even if it's currently playing. Ideal for one-shot sound effects like explosions, impacts, or UI feedback.\
|
|
4737
|
+
* While this function can play any audio, it's recommended to use the AudioPlayer component for background music or longer tracks.\
|
|
4738
|
+
* The AudioPlayer component provides additional features like handling browser autoplay policies, fading, and advanced playback control.
|
|
3950
4739
|
* @param playSfxOptions - The options for playing the sound effect.
|
|
3951
4740
|
* @public
|
|
3952
4741
|
* @category Audio
|
|
@@ -3968,7 +4757,9 @@ interface PlaySfxOptions {
|
|
|
3968
4757
|
*/
|
|
3969
4758
|
declare const playSfx: ({ audioSource, volume, loop }: PlaySfxOptions) => void;
|
|
3970
4759
|
/**
|
|
3971
|
-
*
|
|
4760
|
+
* Stops a sound effect by pausing playback and resetting its position to the beginning.\
|
|
4761
|
+
* Useful for immediately silencing sound effects or interrupting looped audio.\
|
|
4762
|
+
* Note that this completely stops the audio - to temporarily pause, use audioSource.pause() directly.
|
|
3972
4763
|
* @param audioSource - The audio source to stop.
|
|
3973
4764
|
* @public
|
|
3974
4765
|
* @category Audio
|
|
@@ -3983,9 +4774,9 @@ declare const stopSfx: (audioSource: HTMLAudioElement) => void;
|
|
|
3983
4774
|
/**
|
|
3984
4775
|
* Symbols to be used as dependency identifiers
|
|
3985
4776
|
* @public
|
|
3986
|
-
* @category
|
|
4777
|
+
* @category Decorators
|
|
3987
4778
|
*/
|
|
3988
|
-
declare const
|
|
4779
|
+
declare const BuiltInDependencyIdentifiers: {
|
|
3989
4780
|
AssetManager: symbol;
|
|
3990
4781
|
CanvasElement: symbol;
|
|
3991
4782
|
CollisionRepository: symbol;
|
|
@@ -3997,4 +4788,4 @@ declare const Symbols: {
|
|
|
3997
4788
|
TimeManager: symbol;
|
|
3998
4789
|
};
|
|
3999
4790
|
|
|
4000
|
-
export { Animation, type AnimationSlice, Animator, type AnimatorOptions, type Archetype,
|
|
4791
|
+
export { Animation, type AnimationOptions, type AnimationSlice, Animator, type AnimatorOptions, type Archetype, AssetManager, AudioPlayer, type AudioPlayerAction, type AudioPlayerOptions, type AudioPlayerState, BallCollider, type BallColliderOptions, BoxCollider, type BoxColliderOptions, BroadPhaseMethods, BuiltInDependencyIdentifiers, 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, type DisabledComponent, 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, 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, disableComponent, fixedRound, gameLogicSystem, gamePhysicsSystem, gamePreRenderSystem, inject, injectable, playSfx, radiansToDegrees, randomFloat, randomInt, range, rgbToHex, stopSfx };
|