Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/excaliburjs/Excalibur. 🎮 Your friendly TypeScript 2D game engine for the web 🗡️ excaliburjs.com
excalibur excaliburjs game-development game-engine game-framework gamedev games html5-canvas typescript
Something went wrong. Try again.
TypeScript
12345678910111213141516171819202122232425262728293031323334353637383940import { Vector } from './vector';
/** * Wraps a vector and watches for changes in the x/y, modifies the original vector. */export class WatchVector extends Vector { constructor( public original: Vector, public change: (x: number, y: number) => any ) { super(original.x, original.y); } public override get x() { return (this._x = this.original.x); }
public override set x(newX: number) { if (newX !== this._x) { this.change(newX, this._y); this._x = this.original.x = newX; } }
public override get y() { return (this._y = this.original.y); }
public override set y(newY: number) { if (newY !== this._y) { this.change(this._x, newY); this._y = this.original.y = newY; } }
override setTo(x: number, y: number): void { this.x = x; this.y = y; }}