Jump to content

Missing DeviceButton def in phaser.d.ts

Tom Atom

Recommended Posts



 just tried to read right mouse click with Phaser.Pointer.rightButton, but I found, that Typescript def says that this is boolean. It should be Phaser.DeviceButton. The same is for middleButton and leftButton. Phaser.DeviceButton is missing in phaser.d.ts completely. So, if you need to read specific mouse buttons, add this into phaser.d.ts (not sure if I put right type to "event"...?):

    class DeviceButton {        constructor(parent: Phaser.Pointer | Phaser.SinglePad, buttonCode: number)        parent: Phaser.Pointer | Phaser.SinglePad;        game: Phaser.Game;        event: any;        isDown: boolean;        isUp: boolean;        timeDown: number;        duration: number;        timeUp: number;        repeats: number;        altKey: boolean;        shiftKey: boolean;        ctrlKey: boolean;        value: number;        buttonCode: number;        onDown: Phaser.Signal;        onUp: Phaser.Signal;        onFloat: Phaser.Signal;        start(event: any, value: number): void;        stop(event: any, value: number): void;        padFloat(value: number): void;        justPressed(duration: number): boolean;        justReleased(duration: number): boolean;        reset(): void;        destroy(): void;    }

 Then change rightButton, leftButton and middleButton defs in Phaser.Pointer class from boolean to Phaser.DeviceButton:

leftButton: Phaser.DeviceButton; // boolean;

 ... and everything works.


Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...