MCPcopy Create free account
hub / github.com/melonjs/melonJS / constructor

Method constructor

packages/melonjs/src/renderable/sprite.js:67–306  ·  view source on GitHub ↗

* @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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

_applyFrameMethod · 0.95
setRegionMethod · 0.95
addAnimationMethod · 0.95
setCurrentAnimationMethod · 0.95
getImageFunction · 0.90
onFunction · 0.90
getRegionMethod · 0.80
getAtlasMethod · 0.80
getNormalTextureMethod · 0.80
parseCSSMethod · 0.80
getMethod · 0.65
getTextureMethod · 0.45

Tested by

no test coverage detected