sprite.d.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import { Vector3 } from "../Maths/math.vector";
  2. import type { Nullable } from "../types";
  3. import type { ActionManager } from "../Actions/actionManager";
  4. import type { ISpriteManager, SpriteManager } from "./spriteManager";
  5. import { Color4 } from "../Maths/math.color";
  6. import { Observable } from "../Misc/observable";
  7. import type { IAnimatable } from "../Animations/animatable.interface";
  8. import { ThinSprite } from "./thinSprite";
  9. import type { Animation } from "../Animations/animation";
  10. /**
  11. * Class used to represent a sprite
  12. * @see https://doc.babylonjs.com/features/featuresDeepDive/sprites
  13. */
  14. export declare class Sprite extends ThinSprite implements IAnimatable {
  15. /** defines the name */
  16. name: string;
  17. /** Gets or sets the current world position */
  18. position: Vector3;
  19. /** Gets or sets the main color */
  20. color: Color4;
  21. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  22. disposeWhenFinishedAnimating: boolean;
  23. /** Gets the list of attached animations */
  24. animations: Nullable<Array<Animation>>;
  25. /** Gets or sets a boolean indicating if the sprite can be picked */
  26. isPickable: boolean;
  27. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  28. useAlphaForPicking: boolean;
  29. /**
  30. * Gets or sets the associated action manager
  31. */
  32. actionManager: Nullable<ActionManager>;
  33. /**
  34. * An event triggered when the control has been disposed
  35. */
  36. onDisposeObservable: Observable<Sprite>;
  37. private _manager;
  38. private _onAnimationEnd;
  39. /**
  40. * Gets or sets the sprite size
  41. */
  42. get size(): number;
  43. set size(value: number);
  44. /**
  45. * Gets or sets the unique id of the sprite
  46. */
  47. uniqueId: number;
  48. /**
  49. * Gets the manager of this sprite
  50. */
  51. get manager(): ISpriteManager;
  52. /**
  53. * Creates a new Sprite
  54. * @param name defines the name
  55. * @param manager defines the manager
  56. */
  57. constructor(
  58. /** defines the name */
  59. name: string, manager: ISpriteManager);
  60. /**
  61. * Returns the string "Sprite"
  62. * @returns "Sprite"
  63. */
  64. getClassName(): string;
  65. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  66. get fromIndex(): number;
  67. set fromIndex(value: number);
  68. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  69. get toIndex(): number;
  70. set toIndex(value: number);
  71. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  72. get loopAnimation(): boolean;
  73. set loopAnimation(value: boolean);
  74. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  75. get delay(): number;
  76. set delay(value: number);
  77. /**
  78. * Starts an animation
  79. * @param from defines the initial key
  80. * @param to defines the end key
  81. * @param loop defines if the animation must loop
  82. * @param delay defines the start delay (in ms)
  83. * @param onAnimationEnd defines a callback to call when animation ends
  84. */
  85. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  86. private _endAnimation;
  87. /** Release associated resources */
  88. dispose(): void;
  89. /**
  90. * Serializes the sprite to a JSON object
  91. * @returns the JSON object
  92. */
  93. serialize(): any;
  94. /**
  95. * Parses a JSON object to create a new sprite
  96. * @param parsedSprite The JSON object to parse
  97. * @param manager defines the hosting manager
  98. * @returns the new sprite
  99. */
  100. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  101. }