* @param {number} x - the x coordinates of the sprite object * @param {number} y - the y coordinates of the sprite object * @param {object} settings - Configuration parameters for the Sprite object * @param {HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|TextureAtlas|CompressedImage|strin
(x, y, settings)
| 65 | * videoSprite.play(); |
| 66 | */ |
| 67 | constructor(x, y, settings) { |
| 68 | // call the super constructor |
| 69 | super(x, y, 0, 0); |
| 70 | |
| 71 | // the shared frame-animation engine — owns this sprite's animation state |
| 72 | // (exposed via the `anim` / `current` / `animationspeed` / `animationpause` |
| 73 | // accessors below) and calls back into `_applyFrame` on each frame change. |
| 74 | // Created up front, before the texture is resolved, so the setup code can |
| 75 | // use the accessors. |
| 76 | this._frameAnim = new FrameAnimation(this, (region) => { |
| 77 | this._applyFrame(region); |
| 78 | }); |
| 79 | |
| 80 | /** |
| 81 | * global offset for the position to draw from on the source image. |
| 82 | * @type {Vector2d} |
| 83 | * @default <0.0,0.0> |
| 84 | */ |
| 85 | this.offset = vector2dPool.get(0, 0); |
| 86 | |
| 87 | /** |
| 88 | * true if this is a video sprite (e.g. a HTMLVideoElement was passed as as source) |
| 89 | * @type {boolean} |
| 90 | * @default false |
| 91 | */ |
| 92 | this.isVideo = false; |
| 93 | |
| 94 | /** |
| 95 | * a callback fired when the end of a video or current animation was reached |
| 96 | * @type {Function} |
| 97 | * @default undefined |
| 98 | */ |
| 99 | // this.onended; |
| 100 | |
| 101 | /** |
| 102 | * The source texture object this sprite object is using |
| 103 | * @type {TextureAtlas} |
| 104 | */ |
| 105 | this.source = null; |
| 106 | |
| 107 | /** |
| 108 | * backing field for the `normalMap` accessor — see the getter/setter |
| 109 | * defined on the class for the public API and validation rules. |
| 110 | * @ignore |
| 111 | */ |
| 112 | this._normalMap = null; |
| 113 | |
| 114 | /** |
| 115 | * flicker settings |
| 116 | * @ignore |
| 117 | */ |
| 118 | this._flicker = { |
| 119 | isFlickering: false, |
| 120 | duration: 0, |
| 121 | callback: null, |
| 122 | elapsed: 0, |
| 123 | }; |
| 124 |
nothing calls this directly
no test coverage detected