Jump to content

onInputDown is null


MrRoboman
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

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