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?:confused:
Printable View
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?:confused:
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 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:
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.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
Hope this helps,
ISDP