Jump to content

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


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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...