onInputDown shenanigans

Recommended Posts

		<script src="phaser.js"></script>
		<h1>Card Game</h1>
	    var config = {
	        type: Phaser.AUTO,
	        width: 1200,
	        height: 1000,
	        scene: {
	            preload: preload,
	            create: create,
	            update: update

	    game = new Phaser.Game(config);

	    var counter = 0;

	    function preload ()
	        this.load.image('background', 'assets/background.jpg');
	        this.load.image('wolf', 'assets/wolf.png')

	    function create ()
	        this.add.image(600, 500, 'background');

	        creature =;
	        creature.inputEnableChildren = true;

	        wolf = creature.create(600, 500, 'wolf');	
	        wolf.onInputDown.add(listener, this);

	    function listener(sprite){

	    function update () {


The code above is supposed to log "click" on the console whenever the wolf image is clicked but instead I get an error


 Uncaught TypeError: Cannot read property 'add' of undefined

after multiple hours of trying to fix it, I conceded and came to ask for help. 


Many thanks in advanced.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.