Jump to content

Dragging a group, and clicking on sprites


farzher
 Share

Recommended Posts

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

  • 1 year later...

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

 Share

  • Recently Browsing   0 members

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