Jump to content

How to listen to an image tap on a mobile device?


lpbr
 Share

Recommended Posts

I have this simple game for small children that consists on several images that when tapped should produce a sound.

I got it working on the computer (mouse click) but not on mobiles (finger tap) and I suspect that's because I am listening to the wrong event. Could someone tell me how to listen to a image "tap"?

My current working code for computers is:

// I am adding the functions and listeners dynamically with a
// loop so aAssets is an array containing the image elements

// enable input
window[aAssets[i]].inputEnabled = true;

// create the function to be triggered by the listener
window['lst'+aAssets[i]] = function (me) {
   alert (me.key);
}

// add the respective listener
window[aAssets[i]].events.onInputDown.add(window['lst'+aAssets[i]], this);

PS: I found the events "onDown" and "onTap" and tried them but both causes an error when added.

Thanks!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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