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

Method angleTo

packages/melonjs/src/renderable/renderable.js:641–657  ·  view source on GitHub ↗

* return the angle to the specified target * @param {Renderable|Vector2d|Vector3d} target * @returns {number} angle in radians

(target)

Source from the content-addressed store, hash-verified

639 * @returns {number} angle in radians
640 */
641 angleTo(target) {
642 const a = this.getBounds();
643 let ax;
644 let ay;
645
646 if (target instanceof Renderable) {
647 const b = target.getBounds();
648 ax = b.centerX - a.centerX;
649 ay = b.centerY - a.centerY;
650 } else {
651 // vector object
652 ax = target.x - a.centerX;
653 ay = target.y - a.centerY;
654 }
655
656 return Math.atan2(ay, ax);
657 }
658
659 /**
660 * return the distance to the specified target

Callers 1

lookAtMethod · 0.95

Calls 2

getBoundsMethod · 0.95
getBoundsMethod · 0.65

Tested by

no test coverage detected