ikaruga Posted August 4, 2020 Share Posted August 4, 2020 Here's the code in question: https://pixijs.io/examples/#/interaction/dragging.js bunny .on('pointerdown', onDragStart) .on('pointermove', onDragMove); function onDragStart(event) { // store a reference to the data // the reason for this is because of multitouch // we want to track the movement of this particular touch this.data = event.data; } // this is the example onDragMove function onDragMove() { if (this.dragging) { const newPosition = this.data.getLocalPosition(this.parent); this.x = newPosition.x; this.y = newPosition.y; } } // why doesn't this work? function onDragMoveModified(event) { if (this.dragging) { const newPosition = event.data.getLocalPosition(this.parent); this.x = newPosition.x; this.y = newPosition.y; } } As per the docs for the InteractionEvent, the `event.data` presumably has the data for the current drag event. https://pixijs.download/dev/docs/PIXI.InteractionEvent.html Can someone explain to me why we have to store the start `event.data` in the current object? I don't understand why using the latest event (as in onDragMoveModified) doesn't work? To clarify, when you try that code, the result is jumpiness on multi touch Quote Link to comment Share on other sites More sharing options...
jonforum Posted August 5, 2020 Share Posted August 5, 2020 in most case you will maybe prefer bind the objet, or pass this if you use classes bunny.on("onDragStart",onDragStart,bunny); Quote Link to comment Share on other sites More sharing options...
leeda Posted August 6, 2020 Share Posted August 6, 2020 onDragMoveModified does not seem to be listen. .on('pointermove', onDragMoveModified); 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.