Jump to content

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 = this.add.group();
	        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.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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