You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation for GAMEOBJECT_DRAG and GAMEOBJECT_DRAG_END both say that the x and y values are in "world space", however this doesn't seem to be correct because if you are dragging an object that is inside of a container, you can still use the values directly to set the position of the object to where the mouse is.
However, there is another contradiction which is the GAMEOBJECT_DRAG_END x and y values seem to be in the local space of the object being dragged, so they differ from the GAMEOBJECT_DRAG values.
Example Test Code
export default class DragEventIssue extends Phaser.Scene {
create() {
this.add.rectangle(this.scale.width * .75, this.scale.height / 2, 100,100, 0xff0000).setInteractive({ draggable: true })
.on(Phaser.Input.Events.GAMEOBJECT_DRAG, (pointer, x, y) => console.log(x,y))
.on(Phaser.Input.Events.GAMEOBJECT_DRAG_END, (pointer, x, y) => console.log(x,y)); // should return the same values but doesn't
const r = this.add.rectangle(this.scale.width / 4, this.scale.height / 2, 100,100, 0xff0000).setInteractive({ draggable: true })
.on(Phaser.Input.Events.GAMEOBJECT_DRAG, (pointer, x, y) => {
console.log(x,y);
r.setPosition(x,y);
})
.on(Phaser.Input.Events.GAMEOBJECT_DRAG_END, (pointer, x, y) => console.log(x,y)); // should return the same values but doesn't
}
}
Additional Information
The documentation should probably be updated to clarify that the x/y values are in the "parent space" - which might be the scene and thus "world space" but might be in a container's space. The GAMEOBJECT_DRAG_END values should be fixed to return the same values as the GAMEOBJECT_DRAG event, or at least the documentation should be updated to indicate what space they are in to avoid confusion. This may affect other DRAG events such as DRAG but I haven't checked.
The text was updated successfully, but these errors were encountered:
Version
Description
The documentation for GAMEOBJECT_DRAG and GAMEOBJECT_DRAG_END both say that the
x
andy
values are in "world space", however this doesn't seem to be correct because if you are dragging an object that is inside of a container, you can still use the values directly to set the position of the object to where the mouse is.However, there is another contradiction which is the GAMEOBJECT_DRAG_END
x
andy
values seem to be in the local space of the object being dragged, so they differ from the GAMEOBJECT_DRAG values.Example Test Code
Additional Information
The documentation should probably be updated to clarify that the x/y values are in the "parent space" - which might be the scene and thus "world space" but might be in a container's space. The GAMEOBJECT_DRAG_END values should be fixed to return the same values as the GAMEOBJECT_DRAG event, or at least the documentation should be updated to indicate what space they are in to avoid confusion. This may affect other DRAG events such as DRAG but I haven't checked.
The text was updated successfully, but these errors were encountered: