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 |
Example
let mouse = new Mouse(engine, canvas, { stroke: 'blue', strokeWeight: 3 })
Methods
#
draw()
Draws the mouse constraints to the p5 canvas
#
on(eventName, action)
Subscribes a callback function to the given object's eventName
Parameters:
Name |
Type |
Description |
eventName |
string
|
|
action |
function
|
|
#
setOffset(offset)
Sets the mouse position offset e.g. { x: 0, y: 0 }
Parameters:
Name |
Type |
Description |
offset |
object
|
|