weratius Posted October 18, 2015 Share Posted October 18, 2015 Hello, everybody. How can I set an element to the top in the group after dragging? here is the initialization: The LAYERS:this.layers = {profileLayer: game.add.group(),itemsLayer: game.add.group()} initDrag: function(currentElement) {game.physics.arcade.enable(currentElement);currentElement.inputEnabled = true;currentElement.input.enableDrag(false, true); //THIS IS IMPRORTANTcurrentElement.events.ondragStart.add(this.startDrag, this);currentElement.events.ondragStop.add(this.stopDrag, this);},createSprite: function(x, y, elementName, layerType) {var obj = game.add.sprite(x, y, elementName);obj.fixedToCamera = true;obj.anchor.set(0.5, 0.5);this.initDrag(obj);this.layers.profileLayer.add(obj);} Here is the drag events:startDrag: function(currentElement) {//some codethis.layers.itemsLayer.bringToTop(currentElement);//some code},stopDrag: function(currentElement) { //some codecurrentElement.bringToTop();}I can't understand why the dragging element is still under other elements I tried to use " currentElement.input.enableDrag(false, true); " and " bringToTop " on and after dragging Thank in advance) Link to comment Share on other sites More sharing options...
jmp909 Posted October 18, 2015 Share Posted October 18, 2015 I'm a bit confused because they already sort to top by default when you set thiscurrentElement.input.enableDrag(false, true)http://phaser.io/sandbox/xSNZmouE/play do you not want to bring it top top until drag is complete? note ..bringToTop only sorts within their own group though weratius 1 Link to comment Share on other sites More sharing options...
weratius Posted October 18, 2015 Author Share Posted October 18, 2015 I'm a bit confused because they already sort to top by default when you set thiscurrentElement.input.enableDrag(false, true)http://phaser.io/sandbox/xSNZmouE/play do you not want to bring it top top until drag is complete? note ..bringToTop only sorts within their own group thoughI don't understand that too, I consoled log the group which the dragging element belonged to and I saw that the element it the latest in the group.children array I really can't get it at all Link to comment Share on other sites More sharing options...
jmp909 Posted October 18, 2015 Share Posted October 18, 2015 You'll need to put something on jsfiddle/codepen/phaser sandbox please etc in order to investigate further. J Link to comment Share on other sites More sharing options...
Recommended Posts