lars Posted June 16, 2018 Share Posted June 16, 2018 Hello All I trying to make a object be dragged into a container and then be a child of this container like this: //places in a pointerup event let bl = otc.skeleton.findBone("left-hand-bone"); let point = oc.toGlobal({ 'x': bl.x, 'y': bl.y }); this.position.set(point.x - (oc.width - 5), point.y - (oc.height - 30)); // oCon.toLocal(this.position, this.parent, this.newPosition);//this i did not manage to get to work oc.addChild(this);//the container where drop the object(this) this.position.set(point.x - (oc.width - 30), point.y - (oc.height + 30)); And work fairly ? But then when i want to drag the object out of the container again i gives me som problems: //placed in a pointerdown event if (globals.objectUsed) { // if the object is dragged to the new container in first place oCon.addChild(this); // send it back to its original container this.position.set(e.data.getLocalPosition(oCon).x, e.data.getLocalPosition(oCon).y); globals.objectUsed = false; isIntersected = false; } It´s kind of work. But the idea is that when the object is placed the first time and I want to drag it back to the original container its should happend when I startDrag(pointerdown), but i have to wait for the pointerup otherwise I still drag the object in its parent container (whichs is having a drag method. Could anyone guide be in the right direction it would be so nice ... hopefully me explaining its not to much rubbish ? Regards Lars Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 16, 2018 Share Posted June 16, 2018 why do you use "width" and "height" there? I think any drag examples does not use it: https://pixijs.io/examples/#/projection/basic.js (this is for custom plugin, but the drag code is good) Do you know that position of spine object is not left-top point? Also, W/H can change every frame. Quote Link to comment Share on other sites More sharing options...
lars Posted June 18, 2018 Author Share Posted June 18, 2018 Hi Ivan My drag and is not included in my example, it´s work ok, only, some attemp to add a object from one container to another container, and atemp to get it back to the original container ? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 18, 2018 Share Posted June 18, 2018 Make a fiddle, I'll help. 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.