bonez001 Posted October 20, 2016 Share Posted October 20, 2016 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 More sharing options...
pumuky Posted October 20, 2016 Share Posted October 20, 2016 Hello, You need to enable the input for the object that you want before In your case: cover1.inputEnabled = true; Link to comment Share on other sites More sharing options...
Recommended Posts