Setting position has no effect after re-parenting entity?
AleCie opened this issue · 1 comments
AleCie commented
Image img = new Image(Game1.ResourceManager.GetTexture(inventory.Items[i].Item.Image), new Vector2(64, 64), anchor: Anchor.AutoInline);
img.Draggable = true;
img.OnStartDrag += (Entity e) => {
img.RemoveFromParent();
UserInterface.Active.AddEntity(img);
};
img.WhileDragging += (Entity e) =>
{
img.SetPosition(Anchor.TopLeft, new Vector2(Mouse.GetState().Position.X, Mouse.GetState().Position.Y));
};
img.OnStopDrag += (Entity e) =>
{
//img.SetPosition(Anchor.AutoInline, Vector2.Zero);
img.RemoveFromParent();
storagePanel.AddChild(img);
// img.SetPosition(Anchor.TopLeft, Vector2.Zero);
img.SetOffset(Vector2.Zero);
};
storagePanel.AddChild(img);
Left, before dragging, right, after dragging.
I am not sure what I am doing wrong, but can't find any solution to this.
Is this the intended usage of draggable entities?
RonenNess commented
Fixed, the change is here if you want to copy it before next nuget release:
https://github.com/RonenNess/GeonBit.UI/blob/master/GeonBit.UI/Source/Entities/Entity.cs#L1026
Thanks!