Reference pmouseX

pmouseX

A Number system variable that tracks the mouse's previous horizontal position.

In 2D mode, pmouseX keeps track of the mouse's position relative to the top-left corner of the canvas. Its value is mouseX from the previous frame. For example, if the mouse was 50 pixels from the left edge of the canvas during the last frame, then pmouseX will be 50.

In WebGL mode, pmouseX keeps track of the mouse's position relative to the center of the canvas. For example, if the mouse was 50 pixels to the right of the canvas' center during the last frame, then pmouseX will be 50.

If touch is used instead of the mouse, then pmouseX will hold the x-coordinate of the last touch point.

Note: pmouseX is reset to the current mouseX value at the start of each touch event.

Examples

Notice any errors or typos? Please let us know. Please feel free to edit src/events/mouse.js and open a pull request!

Related References