MCPcopy Create free account
hub / github.com/melonjs/melonJS / dispatchPointer

Function dispatchPointer

packages/melonjs/tests/ui-interaction.spec.js:21–35  ·  view source on GitHub ↗
(type, gameX, gameY)

Source from the content-addressed store, hash-verified

19// coordinates via the canvas bounding rect so the test is independent of
20// how `scale: "auto"` sized/positioned the canvas in the runner page
21const dispatchPointer = (type, gameX, gameY) => {
22 const canvas = video.renderer.getCanvas();
23 const rect = canvas.getBoundingClientRect();
24 canvas.dispatchEvent(
25 new PointerEvent(type, {
26 clientX: rect.left + (gameX * rect.width) / canvas.width,
27 clientY: rect.top + (gameY * rect.height) / canvas.height,
28 pointerId: 1,
29 width: 1,
30 height: 1,
31 isPrimary: true,
32 bubbles: true,
33 }),
34 );
35};
36
37const syncBroadphase = () => {
38 game.world.broadphase.clear();

Callers 1

Calls 1

getCanvasMethod · 0.80

Tested by

no test coverage detected