From 8e5e48dd820a0b936f725a51150f9bd8922f8844 Mon Sep 17 00:00:00 2001 From: Galin Simeonov Date: Wed, 29 Sep 2021 13:07:50 +0300 Subject: some touch screen support --- snek.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'snek.js') diff --git a/snek.js b/snek.js index 4e83075..df66c18 100644 --- a/snek.js +++ b/snek.js @@ -106,6 +106,12 @@ function initialise() context=canvas.getContext("2d"); canvas.addEventListener('mousemove', e => { cursor.x=e.offsetX; cursor.y=e.offsetY; }); + canvas.addEventListener('touchmove', e => + { + cursor.x=e.changedTouches[0].clientX; + cursor.y=e.changedTouches[0].clientY; + + }); mice=[]; mice.push(createMouse(200,100,1,normalMouseSpeed,normalMouseSize)); -- cgit v1.2.3