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

Method constructor

packages/melonjs/src/camera/camera2d.ts:222–296  ·  view source on GitHub ↗

* @param minX - start x offset * @param minY - start y offset * @param maxX - end x offset * @param maxY - end y offset

(minX: number, minY: number, maxX: number, maxY: number)

Source from the content-addressed store, hash-verified

220 * @param maxY - end y offset
221 */
222 constructor(minX: number, minY: number, maxX: number, maxY: number) {
223 super(minX, minY, maxX - minX, maxY - minY);
224
225 this.AXIS = {
226 NONE: 0,
227 HORIZONTAL: 1,
228 VERTICAL: 2,
229 BOTH: 3,
230 };
231
232 this.bounds = boundsPool.get();
233
234 this.smoothFollow = true;
235
236 this.damping = 1.0;
237
238 this.near = -1e6;
239
240 this.far = 1e6;
241
242 this.projectionMatrix = new Matrix3d();
243
244 this.invCurrentTransform = new Matrix3d();
245
246 // offset for shake effect
247 this.offset = new Vector2d();
248
249 // target to follow
250 this.target = null;
251
252 // default value follow
253 this.follow_axis = this.AXIS.NONE;
254
255 // active camera effects
256 this.cameraEffects = [];
257
258 // default screen position (top-left of canvas)
259 this.screenX = 0;
260 this.screenY = 0;
261 this.zoom = 1;
262 this.worldProjection = new Matrix3d();
263 this.screenProjection = new Matrix3d();
264 this._worldView = new Bounds();
265 this.autoResize = true;
266
267 // default camera name
268 this.name = "default";
269
270 // set a default deadzone
271 this.setDeadzone(this.width / 6, this.height / 6);
272
273 // for backward "compatibility" (in terms of behavior)
274 this.anchorPoint.set(0, 0);
275
276 // enable event detection on the camera
277 this.isKinematic = false;
278
279 // camera manages its own FBO lifecycle in draw()

Callers

nothing calls this directly

Calls 6

setDeadzoneMethod · 0.95
onFunction · 0.90
getMethod · 0.65
setMethod · 0.45
setMinMaxMethod · 0.45

Tested by

no test coverage detected