Jump to content

Can I use divs as virtual controls?


Recommended Posts


Can I use divs as virtual controls? 

I have a div called "leftButton" and I want you to hold down the function "turnLeft()" is executed.
The idea is that the vehicle turn left while the div is pressed.
var interval; 	$("#leftButton").mousedown(function () {		interval = setInterval(function() { game.state.states.main.turnLeft(); }, 50);	}).mouseup(function () {		clearInterval(interval);	});
On mobiles, currently the operation is not correct, since a delay or the car continues to rotate indefinitely occurs.
Desktop works by pressing the div with the mouse.
My goal is to use divs for the interface (Buttons, records, lives, etc.), around the game screen.
Kind regards
PD. Sorry for my English language
Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...