+ 8
your code takes the location clicked on the entire screen rather than the canvas alone so when you click on the canvas, it takes the location clicked relative to the entire screen you can notice that better if you set margin-left:30%; margin-top:30%; to the canvas in the css. you will notice it then what you need to do is find the offset of the screen edge to the canvas and play with that good luck :)
6th Mar 2017, 10:03 AM
Burey
Burey - avatar
+ 8
hmm you made some changes and now the touch aint working well on my phone ;_; edit getting undefined for x and y
6th Mar 2017, 10:14 AM
Burey
Burey - avatar
+ 8
try playing with: pos=c.getBoundingClientRect(); var x = evt.clientX-pos.left ; var y = evt.clientY-pos.top ;
6th Mar 2017, 10:25 AM
Burey
Burey - avatar
+ 7
try: var pos=c.getBoundingClientRect(); touch=evt.touches[0]; var x = touch.clientX-pos.left ; var y = touch.clientY-pos.top ;
6th Mar 2017, 12:37 PM
Burey
Burey - avatar
+ 6
at last xD good job >:p
6th Mar 2017, 12:50 PM
Burey
Burey - avatar
+ 6
also, add this at the start of the handler evt.preventDefault(); it will prevent scrolling down when you move around
6th Mar 2017, 12:53 PM
Burey
Burey - avatar