Jump to content

Draw rectangle over the game


Recommended Posts

Hello, what i try to do is that my user will be able to draw on the game a figure, such as a rectangle, then I use the coordinates of the rectangle that he draw and when some sprite enter to that area send a message.
How can i make that my user whit the mouse can draw over the game?

Link to comment
Share on other sites

you can create a Phaser.Rectangle( x, y, width, height ); on mouse down / release

something like that (not tested).

let rectX1 = 0;
let rectY1 = 0;
let rectX2 = 0;
let rectY2 = 0;
            RectX1 = event.x;
            RectX2 = event.y;

            RectX2 = event.x;
            RectY2 = event.y;

const rectangle = new Phaser.Rectangle( rectX1, rectY1, rectX2, rectY2 );

regards :)

Link to comment
Share on other sites


  • Recently Browsing   0 members

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