I am trying to create a game for crossing the road, I did for desktop version where I can move the player by using keys to cross the road, but now I want to do it for mobile version, any idea how to add keys to move the player on mobile devices. Thanks
Asked
Active
Viewed 241 times
2 Answers
0
You can play with touch events in touch enabled devices or you can provide arrows to make movement of object..

Rayon
- 36,219
- 4
- 49
- 76
-
thank you, but I don't have much experience on this, any idea how to add arrow to make movement of the object. – user1929483 May 03 '15 at 11:14
-
Design something like this : http://www.onlywebpro.com/wp-content/uploads/2011/10/keyboard_events_in_canvas.jpg And just bind your movement functions to this arrow click events.. – Rayon May 03 '15 at 11:16
0
Never developed a game - so i'm not sure if you are using jQuery too. If so there is a great plugin for handling mobile devices: https://jquerymobile.com/
Instead of click you have events like 'touchstart' and 'touchend' and you can also directly combine them with click:
on('click touchstart,function(){});
Hope this helps!

Fabian Lurz
- 2,029
- 6
- 26
- 52