Drag N Drop
by Rich Hudson · in Torque X 2D · 11/11/2007 (8:18 am) · 5 replies
Has anyone implemented this? If so does anyone have an example (code) ?
I have a decent inventory system working, including chests, inventory screens and equiped slots. But I really do need drag and drop.
R.
I have a decent inventory system working, including chests, inventory screens and equiped slots. But I really do need drag and drop.
R.
#2
Rich
11/13/2007 (4:52 pm)
I also just finished it. Wasn't hard in the end. Since I already had a robust inventory system, all I realy had to do was track the object being dragged by changing its position to match the mouse, and then handle 2 things, 1) Did they drop onto a valid slot, 2) if they did, was there already an item there (pick it up). Wish I could add a screenshot here.Rich
#3
11/13/2007 (6:58 pm)
Sounds cool bro, I was just about to post what I had. Which was basically making the object track the mouse while the button was held down. I wrote a component to handle it and attached it to a scene object that represented a mouse pointer. How did you go about implementing it? I'm just wondering what the most elegant way to deal with the mouse is with TX.
#4
Appreciate the effort and sorry if I wasted any of your time.
R.
11/15/2007 (5:05 pm)
I did not use a scene object as the mouse pointer b/c that will not show up in front of an inventory screen unles you also make that a scene object which I didnt. I have an inventoryComponent which handles the players inventory, and the mouse object handles the right/left clicks - right for dragging, left for auto-equiping. I am trying to emulate NWN2, but am not quite there yet.Appreciate the effort and sorry if I wasted any of your time.
R.
#5
11/15/2007 (9:01 pm)
Nah dude, I'm participating here because I believe it will make me better as well as help others. Thanks for the reply, take it easy man.
Torque Owner Joshua A. Thomas
These are some of my initial thoughts.
The mouse can handle drag n drop, with an object type indicating which dragable objects and drop targets, or each item can handle it's own drag n drop. I'm going to try it both ways.