Question

I've been trying to build a game using Crafty.js. I have an image that serves as a button, and once the user clicks on it he will be led to the next page. However, for some reason the mouse click just isn't firing. Any ideas?

Crafty.scene('Main', function () {
  Crafty.background("url('images/homeBackground.jpg')");
  Crafty.e('2D, DOM, Mouse, next').attr({ //next is the image
    x: 600,
    y: 600,
    w: 100,
    h: 50
  }).bind('click', function (e) {
    alert("Here?"); //this isn't firing
  });
});
Was it helpful?

Solution

Event names are case sensitive, you should bind to the Click event.

More details at: http://craftyjs.com/api/Mouse.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top