MrRoboman Posted February 16, 2014 Share Posted February 16, 2014 Hello, I basically cloned the Phaser example 02 - Click on an image and I am getting an error when trying to add the listener to my sprite. Error: Uncaught TypeError: Cannot call method 'add' of null The problem line is commented below. Has anyone else come across this?function preload() { game.load.image('pic','assets/Pic.jpg');}function create() { var img = game.add.sprite(0,0,'pic'); img.input.enabled = true; //Here is where I get the error //Uncaught TypeError: Cannot call method 'add' of null img.events.onInputDown.add(listener, this);}function listener(){ console.log("click");} Link to comment Share on other sites More sharing options...
rich Posted February 16, 2014 Share Posted February 16, 2014 img.inputEnabled = true; Link to comment Share on other sites More sharing options...
MrRoboman Posted February 16, 2014 Author Share Posted February 16, 2014 Wow! I knew it had to be simple. Thanks, Rich! Link to comment Share on other sites More sharing options...
Recommended Posts