farzher Posted May 10, 2014 Share Posted May 10, 2014 I have a group of tiles that I want to drag around. This is the behavior I want:Clicking a tile in the group should trigger a click event on it.Dragging anywhere should drag the group.If you released from a drag, it shouldn't trigger a click event on any sprite. Right now I'm using `this.events.onInputUp.add` on my tiles, so when I finish dragging it still triggers a click event. Link to comment Share on other sites More sharing options...
farzher Posted May 11, 2014 Author Share Posted May 11, 2014 I added a global `dragged` boolean, that I set to false on mousedown, and true when I dragOn mouseup, I only consider it a click if `dragged` is false. I think this stuff should be part of the framework, but maybe it's not a common enough use case. Link to comment Share on other sites More sharing options...
umair-khan Posted July 20, 2015 Share Posted July 20, 2015 Hi!..I know this is an old post but I have encountered a similar problem.How did you detect click on the child sprites in group? So far I am doing this but it is only detecting click on the last child in group. create() { var parent = game.add.group(); var allSprites = [ 'sprite1', 'sprite2', 'sprite3']; for (i=0; i<3; i++){ childImage = parent.create( game.world.centerX, game.world.centerY+ (i*30), allSprites); childImage.anchor.setTo(0.5, 1); childImage.inputEnabled = true; childImage.input.useHandCursor = true; }}update(){ childImage.events.onInputDown.add(changeText, this);} Link to comment Share on other sites More sharing options...
Recommended Posts