Jump to content

Swapping drag targets at runtime: drag parent of a dragged object when over a certain threshold


vorrin
 Share

Recommended Posts

Hello! 

 

I've got a situation as the below:

 

post-10465-0-71458900-1416937759.png

 

two tiles (red) are contained within a larger one (blue). All tiles are sprites, and the red ones are children of the blue one. I want to be able to drag the tiles individually (ie. so I can drag 6 on 4), but if I drag one of them outside of the blue rectangle, I want the drag target, to become the larger, blue tile (containing the smaller ones). 

 

I made much of this work, I deactivate input on the blue tile, so that its red children, with input on,  can be dragged , I detect when a red tile is dragged outside of the blue tile's hit area. My problem now, is, I don't know how to make phaser change the currently dragged item from a red tile, to the big blue one. 

 

I've tried a bunch of hacks, eventually got it half working with calling stop() and start() by hand on game.input.activePointer , but unsurprisingly that does not go well with touch input, and looks in general as a terrible way of doing that.

 

Would anyone have a better idea on how to do this?

 

Thanks! 

 

(here is a snippet of horrible code, showing the current solution, which happens in the update loop of the red tiles)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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