Computer Science Canada Mouse Help |
Author: | marshymell0 [ Thu May 18, 2006 5:40 pm ] | ||
Post subject: | Mouse Help | ||
Well what I have is a picture that I want the user to move around. The procedure I followed was: 1. Put picture onto screen 2.Take a snapshot of the picture 3.Wait for user to click mouse 4.Move the picture according to mouse 5.If the user's mouse goes out of the boundary, reset the location (only a certain area is allowed to move the picture) This is what I came up with.
The problem is, when I move the picture around, it drags along sort of a "trail" of the old picture, and the restrictions don't work. I'm thinking somehting is wrong with the co-ordinates of the bgID, but I can't figure out what. And it's in a procedure because the user clicks a button to start moving the picture. Thanks. |
Author: | TheOneTrueGod [ Thu May 18, 2006 5:43 pm ] |
Post subject: | |
Well, problem number one is theres no cls, however, if you have other things being drawn, and other things moving while the picture is moving, simply inserting a cls will not help you. You're going to have to get rid of that nested loop, and find another way to do it. If this is the only thing you have to do, all you have to do is insert a cls. |
Author: | blaster009 [ Thu May 18, 2006 5:55 pm ] |
Post subject: | |
Like mentioned above, you need to cls the screen. Otherwise, it keeps the picture of what was there before. You might also want to look into View.Update and View.Set in order to prevent flicker. |
Author: | marshymell0 [ Thu May 18, 2006 7:55 pm ] |
Post subject: | |
well the reason why I'm not using view.update and cls is because this is part of a program (as in a section of the output screen), which is sort of like a canvus/paint thing. Bascially, this procedure is for a button, and when the user clicks, he/she can drag a picture around wherever he/she wants, without it going out of the canvus. So if I cls, and the person had put other pictures on the canvus before, then the whole canvus in which the user draws/adds things will be gone. THat's why I have two pictures, one to overrwrite the other one so that a "trail" doesn't appear. That's why I don't use something like just drawfillbox overtop of it in the loop. Another problem is how do I make it so that if the user clicks the button again, the old picture is not deleted. As in, the user can click the button as many times as possible, and keep moving the picture around. Because right now, because the picture is assigned to only one variable, I can only have the picture displayed once. |
Author: | TheOneTrueGod [ Thu May 18, 2006 9:05 pm ] |
Post subject: | |
If thats the case, then you can't do it with the nested loop. You have to update it's position every iteration of the main loop. |