|
-
May 4th, 2002, 02:28 PM
#1
Thread Starter
Member
making objects move with BitBlt
i've just learnt the basics of BitBlt but can't get anything to move.
say when a timer goes off you move a picture to the right a bit so it looks as if it's going along. what would the code be?
this should be the last of my BitBlt posts if it gets any answers that work
-
May 4th, 2002, 02:32 PM
#2
Good Ol' Platypus
In an interval (ex. a Do... DoEvents... Loop or Timer), you can just change the X/Y values (and even the thing you are "blitting") to your BitBlt call. This way simple animation and moving (walking animations too ) can be achieved.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
May 4th, 2002, 06:25 PM
#3
Fanatic Member
And don't forget that you have to refresh the form you're blitting to to see any movement...
Never argue with fools, they will only drag you down to their level, and beat you with experience.
Q: How do you tell an experienced hacker from a novice?
A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer
-
May 4th, 2002, 06:57 PM
#4
Thread Starter
Member
thanks
this is part of my code:
VB Code:
Private Sub Timer1_Timer()
intChange = intChange + 10
BitBlt Picture2.hDC, intChange, 0, 1215, 1455, Picture1.hDC, 0, 0, SRCCOPY
Me.Refresh
End Sub
it loads a new pic in the picture2 every time
should a new one load every time and if yes how do i get rid of the old ones?
-
May 6th, 2002, 03:38 PM
#5
Try it this way:
Code:
retval = BitBlt(DestPicture.hDC, DestPictureUpperLeft,DestPictureX,DestPictureY, DestPictureWidth, DestPictureHeight, SourcePicture.hDC, SourcePictureLeftCorner,SourcePictureTopCorner, SRCCOPY)
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
May 6th, 2002, 06:55 PM
#6
Well basically, you need to store your X and Y coordinates in variables, and anytime you want to move the image, you just change the X and Y coordinates.
In the example above, if I wanted to move the picture to the right by 10 pixels I would use:
Code:
DestPictureX=DestPictureX+10
DestPictureY=DestPictureY+10
Then I'd call the function again, so it will redraw the picture in the new location.
Code:
retval = BitBlt(DestPicture.hDC, DestPictureUpperLeft,DestPictureX,DestPictureY, DestPictureWidth, DestPictureHeight, SourcePicture.hDC, SourcePictureLeftCorner,SourcePictureTopCorner, SRCCOPY)
-
May 6th, 2002, 08:31 PM
#7
Good Ol' Platypus
To remove the old picture, use the .Cls method of the picturebox.
To get rid of the flickering that comes from this method, search the board for double buffering, or put the picbox on AutoRedraw and use .Refresh after your BitBlt call(s).
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|