Muhammad Adnan Posted March 22, 2018 Share Posted March 22, 2018 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 ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 22, 2018 Share Posted March 22, 2018 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. Muhammad Adnan 1 Quote Link to comment Share on other sites More sharing options...
Muhammad Adnan Posted March 23, 2018 Author Share Posted March 23, 2018 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.