Computer Science Canada Question about dragging a picture: |
Author: | Eulogy [ Mon Mar 29, 2004 10:59 am ] |
Post subject: | Question about dragging a picture: |
Hello everyone, It's my first post, so I'm a little nervous. I'm trying to create my first game, and I've encountered a problem. My game idea is simple, a puzzle that the user reassembles. My problem: I have the puzzle pieces in bitmaps, but I don't know how to implement them into my game. What I need to happen: The puzzle pieces need to be able to be clicked, and dragged around the screen freely. Can anyone reply with the source code needed to for 1 bitmap? I can do the rest. Thank you. |
Author: | Paul [ Mon Mar 29, 2004 11:55 am ] |
Post subject: | |
I'd say put the picture variables in arrays, make it so that you don't have to hold the mouse button to move it, like once you click it, you have to click it again to drop it. Update the position of the picture everytime the mouse button is clicked and the x and y is different, then when the user clicks again, it stays in the last recorded position. |
Author: | guruguru [ Mon Mar 29, 2004 11:58 am ] | ||
Post subject: | |||
Heres an idea...
Hope it helped... but I thinck that would only work for one piece, just put the x and y coordinates of the piece in an array, then update them when you move the pic. |
Author: | Tony [ Mon Mar 29, 2004 3:07 pm ] | ||
Post subject: | |||
I imagine it being something like
I also sujest implementing a snap - that is, if the picture is within certain distance of the square, it gets snaped into it, so that user doesn't have to make per pixel adjustments in positioning |