Results 1 to 3 of 3

Thread: Changing a pic with movement...

  1. #1

    Thread Starter
    Junior Member MHD's Avatar
    Join Date
    Nov 2002
    Location
    The Magical World of the Internet
    Posts
    22

    Question 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!!

  2. #2
    Addicted Member
    Join Date
    Oct 2002
    Location
    Somewhere out in space
    Posts
    151
    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!'

  3. #3
    Junior Member ISDP's Avatar
    Join Date
    Mar 2002
    Posts
    28
    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
  •  



Click Here to Expand Forum to Full Width