Jump to content

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


Recommended Posts

Hello, everybody.


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


here is the initialization:



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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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