Mouse

Mouse

Creates a representation of the user's mouse for being able to interact with the Matter.js world.

Constructor

# new Mouse(world, canvas, attributes)

Parameters:
Name Type Description
world engine Pass the Matter.js engine
canvas canvas Pass the drawing canvas
attributes object (Optional) Attributes like color
Source:
Tutorials:
Example
let mouse = new Mouse(engine, canvas, { stroke: 'blue', strokeWeight: 3 })

Methods

# draw()

Draws the mouse constraints to the p5 canvas
Source:

# on(eventName, action)

Subscribes a callback function to the given object's eventName
Parameters:
Name Type Description
eventName string
action function
Source:

# setOffset(offset)

Sets the mouse position offset e.g. { x: 0, y: 0 }
Parameters:
Name Type Description
offset object
Source: