Comments on: Simple drag and drop with snap-to-tiles in XNA http://xnafan.net/2012/07/simple-drag-and-drop-with-snap-to-tiles-in-xna/ XNA tutorials, code and games Fri, 10 Aug 2018 04:55:21 +0000 hourly 1 https://wordpress.org/?v=4.2.22 By: admin http://xnafan.net/2012/07/simple-drag-and-drop-with-snap-to-tiles-in-xna/comment-page-1/#comment-306800 Thu, 12 Mar 2015 07:22:33 +0000 http://xnafan.net/?p=466#comment-306800 Hi Ludo :)

If you read the article to its end, you'll see that the code to make the chess board is under the heading: "Another noteworthy codesample".
If that doesn't make sense, just ask again :).

Kind regards - Jakob

]]>
By: repstyle http://xnafan.net/2012/07/simple-drag-and-drop-with-snap-to-tiles-in-xna/comment-page-1/#comment-299293 Tue, 10 Feb 2015 19:23:23 +0000 http://xnafan.net/?p=466#comment-299293 Hello, thnaks for this tutorial but i don't understand how you create and use the grid shown in the video. Can you explain it ?

]]>
By: admin http://xnafan.net/2012/07/simple-drag-and-drop-with-snap-to-tiles-in-xna/comment-page-1/#comment-67023 Tue, 25 Jun 2013 05:46:37 +0000 http://xnafan.net/?p=466#comment-67023 Hi Tiwi :)

You could solve it this way:
- have a list of all selectable items in the market (you probably already have this)
- when the user clicks the mouse, run through the list of items till you find the item hit (or none, in which case you do nothing :))
- if the user clicked an item:
- toggle the item's "Selected" property (something you need to code yourself)
- maybe alter the drawing of the items when they are selected. Put a border on them, or something like that? :)
- have a list of selected items which you add the selected items to when you select them, and remove the items from when you deselect them
- if the user starts dragging (moving the mouse while the mousebutton is down on top of an item), in every Update() move all the items in the "selected list" the same amount as the mouse has moved since last Update (store the old mouse position at the end of every Update(), so you can calculate the change in movement).
- when the user releases the mousebutton, check to see where that is, and if it is in an "action area" (e.g. Shopping basket, sell area, etc.) then perform the needed action. If releasing the items in an invalid location should result in the items returning to their original position, then you will need to store their original position somewhere as well :)

Note: if your items can overlap you will need to search down through them for mouseclicks from the opposite end of the list as the direction you are drawing them in. So the last drawn (the ones visually on top) will be the first to be hit with the mouse.

Hope this helps! :)

Kind regards - Jakob

]]>
By: Tiwi http://xnafan.net/2012/07/simple-drag-and-drop-with-snap-to-tiles-in-xna/comment-page-1/#comment-67009 Tue, 25 Jun 2013 02:09:21 +0000 http://xnafan.net/?p=466#comment-67009 i want to clicking on each of them to add them to the selected images...

it's like a mini market game, there are some goods... i choose the goods and put it in the basket...
how can i make the code like that?
thanks before... 😀

]]>
By: admin http://xnafan.net/2012/07/simple-drag-and-drop-with-snap-to-tiles-in-xna/comment-page-1/#comment-66935 Mon, 24 Jun 2013 08:23:52 +0000 http://xnafan.net/?p=466#comment-66935 Hi Tiwi :)

How would you like to select those multiple images?
Clicking on each of them to add them to the selected images, or drag a selection rectangle around them?
Write a bit more and I'll see if I can come up with some help for you :)

Kind regards - Jakob

]]>
By: Tiwi http://xnafan.net/2012/07/simple-drag-and-drop-with-snap-to-tiles-in-xna/comment-page-1/#comment-66933 Mon, 24 Jun 2013 08:02:39 +0000 http://xnafan.net/?p=466#comment-66933 hi..i am a new learner of xna game studio and i've learn to drag and drop a multiple images..
how can i make a code to drag and drop some images in this source code?
or in this code just can to drag and drop only one images?

thanks for your help :)

]]>
By: admin http://xnafan.net/2012/07/simple-drag-and-drop-with-snap-to-tiles-in-xna/comment-page-1/#comment-53004 Thu, 27 Dec 2012 21:08:40 +0000 http://xnafan.net/?p=466#comment-53004 Yup - sure, mail me and I'll take a look :)

/Jake

]]>
By: Dnec http://xnafan.net/2012/07/simple-drag-and-drop-with-snap-to-tiles-in-xna/comment-page-1/#comment-52918 Wed, 26 Dec 2012 14:26:13 +0000 http://xnafan.net/?p=466#comment-52918 Good tutorial Kr@rup.dk. I have some doubts about the code.
As much as we have strictly followed your tutorial I cant run correctly the program.
I can drag the tiles, but I can not make it stay in the square. The red color does simple not appear. I can send my source, for you take a look?

]]>