Jump to content

Drag and dropping in a container


Muhammad Adnan
 Share

Recommended Posts

Hey guys, 

So I was fiddling around with Pixi's drag example on their website. I was wondering how can one drop the object in a container. For example I want to move and object and when it reaches near the container it attaches on top of it.

 

I'm really scared of posting this since people might think I want someone to code it for me but I just want to understand the concept and the things I can use, so to say a guide. 

 

Would appreciate the help

Link to comment
Share on other sites

container.toLocal(element.position, element.parent, element.newPosition);
container.addChild(element);

That will move element from whatever it is to that container. For scale and rotation you have to use more advanced version with matrices.

That's for coordinates.

As for dropping inside container, well, you need to do something with shapes.

Prepare to write the code anyway, pixi doesnt have "drop to container" from the box.

Link to comment
Share on other sites

17 hours ago, ivan.popelyshev said:

container.toLocal(element.position, element.parent, element.newPosition);
container.addChild(element);

That will move element from whatever it is to that container. For scale and rotation you have to use more advanced version with matrices.

That's for coordinates.

As for dropping inside container, well, you need to do something with shapes.

Prepare to write the code anyway, pixi doesnt have "drop to container" from the box.

Thanks man, will try something out and post back here with whatever I could Muster up for future use. 

 

Can you, or anyone, point me to the nearest tutorial on how to use Matrices? I don't have the slightest clue how to use them, the documentation doesn't explain much expect for what the functions do, but everything that I wanna achieve is somehow done better and nicer with Matrices. 

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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