|
-
Nov 15th, 2002, 09:30 AM
#1
Thread Starter
Junior Member
Changing a pic with movement...
A question a friend asked me, and i truly am not quite sure waht the heck i am supposed to do. How can i change an image with movement? For example, if i moved left, how woul i make the picture show a ship traveling left?
Vowing to help the helpless, befriend the friendless, and to defeat the... um...defeatless!!
-
Nov 15th, 2002, 09:57 AM
#2
Addicted Member
just load the picture you want in the picture property of the control you use. For exemple, if you use a image (picturebox) control, before you start moving the control, change the picture like this control.picture = loadpicture("filename of the picture") and then move, when it stop moving, just put back the default picture using the same method.
'You keep creatures in cages and release them to fight? That's sick!'
-
Nov 16th, 2002, 05:10 PM
#3
Junior Member
You could try using the Form_MouseMove Function, which will perform an operation whenever the mouse is moved. Use the following code. When the cursor moves for the first time, the positions for X and Y are recorded, and then next time they are compared to the new X and Y values. If the X value has decreased (ie. moved to the left), then you can define the picture accordingly:
Code:
Option Explicit
Dim intOriginalX As Integer
Dim intOriginalY As Integer
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (X < intOriginalX) Then 'If the cursor has moved to the left
'##CODE HERE##
Picture1.Picture = LoadPicture("######")
End If
If (X > intOriginalX) Then 'If the cursor has moved to the right
'##CODE HERE##
Picture1.Picture = LoadPicture("######")
End If
intOriginalX = X 'Defined after the If functions for the next time the cursor is moved
intOriginalY = Y
End Sub
Its not the neatest of codes, you could probably do the same sort of thing with the API function GetCursorPos, the only thing about this code is that it won't change the picture until the second pixel the mouse moves, but that isn't the greatest of problems.
Hope this helps,
ISDP
"Mmm, so I hear they have the internet on computers these days..."
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
|