valentinaCom Posted October 12, 2014 Share Posted October 12, 2014 Hi I have a button that when I press on it, it duplicate (I add a new button) and I want it to automaticly start dragging the new one. right now I need to press again in the new btn to start the drag. here's my code: addItemsToMenu:function(){ var btn = game.add.button(50,50, 'obg'); btn.anchor.set(0.5); btn.onInputDown.add(this.duplicatePic,this); }, duplicatePic:function(e){ var newBtn = game.add.button(e.x, e.y, e.key); newBtn.anchor.set(0.5); newBtn.input.enableDrag(true); newBtn.events.onDragStart.add(this.dragItem,this); newBtn.events.onDragStop.add(this.stopDraItem,this); }help? thank you! Link to comment Share on other sites More sharing options...
j0hnskot Posted October 12, 2014 Share Posted October 12, 2014 Add this in the duplicatePic function: newBtn.input.startDrag(game.input.activePointer); Link to comment Share on other sites More sharing options...
valentinaCom Posted October 13, 2014 Author Share Posted October 13, 2014 great it work! thank you! Link to comment Share on other sites More sharing options...
Recommended Posts