help draging image on the directdraw screen

Started by
2 comments, last by Rhaal 19 years, 4 months ago
I am wanting to know how you can select a tile, bmp , or sprite and drag it to were you want it on the screen? If you know of any tutorials please let me know. I have no idea were to start looking for the answer to this question. Let me try to explain my question. What I want to do is load a directdraw screen and have some sprites load on the left in a row. I want to be able to select one with my mouse and move it on the screen were I want it and just drop it there. How would I accomplish this?
Advertisement
1) On WM_LBUTTONDOWN, determine which sprite (if any) is clicked. You know the position and size of each tile so this should be fairly simple.

2) If a sprite is clicked, set a bool variable and save the current mouse and sprite position (as well as which sprite is selected). Capture mouse input (in case the user moves the mouse out of your window) using SetCapture()

3) On WM_MOUSEMOVE, if a sprite is being dragged, move the sprite to (current mouse position - original mouse position) + original sprite position, then redraw

4) On WM_LBUTTONUP, if a sprite is being dragged, move the sprite as with WM_MOUSEMOVE, release mouse capture, and set the dragging variable to false

5) If you want, you can also cancel everything and move the sprite back when the user presses Esc (WM_KEYDOWN)

Look up these messages on MSDN for details on processing them.
does any one know were I can get a tutorial on this?
Quote:Original post by kingpinzs
does any one know were I can get a tutorial on this?


Well, uavfun just told you. Try following that method. Just store your images location in your image class, then check to see if the mouse button is down and the mouse pointer within that range.

That part is fairly trivial. If you can't figure that out I don't recommend diving into a graphics api immediately.
- A momentary maniac with casual delusions.

This topic is closed to new replies.

Advertisement