Jump to content

"image.events.onInputDown.add" not working


bonez001
 Share

Recommended Posts

Hello. I tried the following code in one state in my game but it didn't work:

 

var x=50,y=300;
state1 = function(){};
state1.prototype = {
    
    preload: function(){
       game.load.image('cover', 'lovely.png');
        
            
    },
    create: function(){
        game.stage.backgroundColor = "#ba55ae";
        cover1 = game.add.sprite(x+100+0,y,'cover');
        cover2 = game.add.sprite(x+100+100,y,'cover');
        cover3 = game.add.sprite(x+100+200,y,'cover');
        cover4 = game.add.sprite(x+100+300,y,'cover');
        cover5 = game.add.sprite(x+100+400,y,'cover');
        cover1.scale.setTo(0.35,0.35);
        cover2.scale.setTo(0.35,0.35);
        cover3.scale.setTo(0.35,0.35);
        cover4.scale.setTo(0.35,0.35);
        cover5.scale.setTo(0.35,0.35);
        
        
        cover1.events.onInputDown.add(listener,this);
       
      
    },
    update: function(){
        
    },
    
    listener: function()
    {
        console.log("lovely");
        
    
    }
};

 

I base it on this example: https://phaser.io/examples/v2/basics/02-click-on-an-image.

Why do you think it is not working?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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