0

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

gman
  • 100,619
  • 31
  • 269
  • 393
user1929483
  • 71
  • 1
  • 7

2 Answers2

0

You can play with touch events in touch enabled devices or you can provide arrows to make movement of object..

Refer this link of touch event details

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