Sakuk3 Posted August 28, 2015 Share Posted August 28, 2015 I´m trying to add a button to a draggable sprite but as soon as i do that i´m not able anymore to click the button.Is there any solution to this problem? Link to comment Share on other sites More sharing options...
Sakuk3 Posted September 1, 2015 Author Share Posted September 1, 2015 Can´t anyone help me? Link to comment Share on other sites More sharing options...
drhayes Posted September 1, 2015 Share Posted September 1, 2015 I bet it's because the sprite isn't set "inputEnabled = true;", but I'm just guessing. What if you didn't add the button to the sprite but set its x/y position in an update method to follow the sprite around? Is that a good workaround? Link to comment Share on other sites More sharing options...
netcell Posted September 2, 2015 Share Posted September 2, 2015 It is actually pretty complicated to add a button to a draggable sprite. My current approach is:- check the distance of the drag in onDrag signal of the draggable sprite- if the drag is not too far, meaning it is a tap: + cancel the drag if needed (reset position) + dispatch the onClick signal of the button.However, if there are multiple buttons or sprite inside the draggable sprite, and/or the button doesn't cover the entire sprite, you would need to see if the tap is on the button or which button it is on by: + set the priorityID of all the buttons to something big (99?) + use the processInteractiveObjects method of Phaser.Pointer to find the button + issues onClick signal of that button. + reset the priorityID of all the buttons to 0 I bet it's because the sprite isn't set "inputEnabled = true;", but I'm just guessing. What if you didn't add the button to the sprite but set its x/y position in an update method to follow the sprite around? Is that a good workaround? If the sprite isn't set inputEnable to true, it wouldn't be able to be dragged I think Sakuk3 wants to drag the sprite while dragging the button too but also can click on the button (like I did with my games). Link to comment Share on other sites More sharing options...
Recommended Posts