Jump to content

Help with Image click detection when using game states


Recommended Posts

Hello all!
I am currently working on modifying source-code for a tutorial by this fine fellow.
I am working to make the example game he has created into an idle clicking game… like Cookie Clicker etc.

I took the phaser example number 2 (Clicking an image) and attempted to re-write it accounting for my game using states…I have not been successful :(

Candy.Game = function(game){// define needed variables for Candy.Game};Candy.Game.prototype = {create: function(){this.stage.backgroundColor = '#fff';this.image1 = this.add.image((Candy.GAME_WIDTH)/2, (Candy.GAME_HEIGHT)/2, 'monster-cover');this.image1.anchor.set(0.5);this.image1.inputEnabled = true;this.text = this.add.text(250, 16, '', { fill: '#B4D9E7' });//this.image1.events.onInputDown.add(listener, this); //This line is where the game stops working},listener: function(){counter++;text.text = "You clicked " + counter + " times!";},update: function(){},};

Any help / tips are greatly appreciated


Thanks in advance!


- TimTation

Link to comment
Share on other sites


  • Recently Browsing   0 members

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