Jump to content

How to set an element to the top in the group after dragging?


weratius
 Share

Recommended Posts

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 IMPRORTANT        currentElement.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 code        this.layers.itemsLayer.bringToTop(currentElement);        //some code    },stopDrag: function(currentElement) {               //some code       currentElement.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

 Share

  • Recently Browsing   0 members

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