1 decade ago by Skwiddy
Been playing around with touch input now for my breakout game. I just want to implement something really simple, like: touch on left of screen -> bat moves left (and vice versa).
I have this in my main...
...and in my paddle entity
This all works fine on the desktop. Both arrow keys and mouse clicks move the paddle, but on a mobile browser touch works really badly (moves once if I click below the game screen towards either far right or far left of the screen).
I thought that mouse input was equivalent to touch input so not sure why it's all going wrong. Any ideas?
I have this in my main...
ig.input.bind( ig.KEY.MOUSE1, "CanvasTouch" );
...and in my paddle entity
update: function(){ this.parent(); if( ig.input.state('left') ) { this.vel.x = -200; }else if( ig.input.state('right') ) { this.vel.x = 200; }else { if(ig.input.state("CanvasTouch")){ if (ig.input.mouse.x < 150){ this.vel.x = -200; }else if(ig.input.mouse.x >600){ this.vel.x = 200; } }else{ this.vel.x = 0 } } }
This all works fine on the desktop. Both arrow keys and mouse clicks move the paddle, but on a mobile browser touch works really badly (moves once if I click below the game screen towards either far right or far left of the screen).
I thought that mouse input was equivalent to touch input so not sure why it's all going wrong. Any ideas?