Krulvis Posted January 7, 2015 Share Posted January 7, 2015 Hey guys, I'm new here but struggling with an issue. Basically I want to enable a click function on a sprite. The sprite consists of one image which is duplicated throughout the width/height of the sprite:The image itself is 32x32 meaning that for every width , height images have to be added.this.tileSprite = this.game.add.tileSprite( x, y, width * 32, height * 32, "solid_block", null, this.blocks ); this.tileSprite.name = name; this.tileSprite.body.immovable = true; this.tileSprite.solid = true; this.tileSprite.inputEnabled = true; this.tileSprite.input.useHandCursor = true; this.tileSprite.events.onInputDown.add(function(){ console.log("Selected: " + this.name); this.select(); }, this);The width and heigh may vary which in my case: width = 3, height = 3 creates a larger sprite consisting out of multiple of the same images: The click function only works when I click on the first image of the sprite (you can see it holds 9 images, 3x3). How do I code it so that wherever on the sprite you click, the onInputDown function is called ? Link to comment Share on other sites More sharing options...
Krulvis Posted January 12, 2015 Author Share Posted January 12, 2015 I fixed this thanks to a guy in chat, apparently you can set a sprites body so you can choose what it is that is intractable. Link to comment Share on other sites More sharing options...
Recommended Posts