Sword Engine

Source: events.ts

// This is the file for global envents
import { Vector } from "./vector";


/**
 * @deprecated
 * @class MouseEvents
 */
export class MouseEvents {
    canvas: HTMLCanvasElement
    mousePosition(e: MouseEvent): Vector {
        let cRect = this.canvas.getBoundingClientRect()
        return new Vector(e.clientX - cRect.left, e.clientY - cRect.top)
    }
    constructor(canvas: HTMLCanvasElement) {
        this.canvas = canvas
    }

    onMouseMove(callback: (e: MouseEvent) => void) {
        this.canvas.addEventListener("mousemove", callback)
    }

    onMouseDown(callback: (e: MouseEvent) => void) {
        this.canvas.addEventListener("mousedown", callback)
    }
}






Made By Vedik Dev - Himanshu Jangid
sword-engine Copyright © 2021 Himanshu.
Documentation generated by JSDoc 3.6.7 on Tue Nov 30 2021 23:12:55 GMT+0530 (India Standard Time) using the TSDoc template.