|
-
Mar 31st, 2000, 11:33 PM
#1
Thread Starter
Junior Member
Can somebody please post a script which has...
buttons that move a picture or icon around the screen
when the icon or picture touches something a MsgBox appears
please? no? go on? cheers
-
Apr 1st, 2000, 03:35 AM
#2
Addicted Member
This will give you something to play with. This code is very basic and could be coded more efficiently, but will demonstrate simple movement.
Size a form at 7995 width x 7680 height
Place a small image 480 x 480 and set TOP to 5640
and LEFT to 480.
Add commmand button and use the following code for it
(This is a continuous loop by using the label continue
code...
continue:
'move bottom left to bottom right
Do
img1.Left = img1.Left + 2 '2 sets the speed
DoEvents
Loop Until img1.Left = 7200
'This should give you some ideas
If img1.Left = 7200 Then
MsgBox "Ouch", , "Title"
End If
'move bottom right to top right
Do
img1.Top = img1.Top - 2
DoEvents
Loop Until img1.Top = 360
'move top right to top left
Do
img1.Left = img1.Left - 2
DoEvents
Loop Until img1.Left = 120
'move top left to bottom left
Do
img1.Top = img1.Top + 2
DoEvents
Loop Until img1.Top = 5640
'move bottom left to top right
Do
img1.Move img1.Left + 2, img1.Top - 2
DoEvents
Loop Until img1.Top = 360: 'shp1.Left
'move top right to centre
Do
img1.Move img1.Left - 2, img1.Top + 2
DoEvents
Loop Until img1.Left = 2200
'move centre to right
Do
img1.Left = img1.Left + 2
DoEvents
Loop Until img1.Left = 5200 '**
'move right to top
Do
img1.Top = img1.Top - 2
DoEvents
Loop Until img1.Top = 360
'move top to left
Do
img1.Left = img1.Left - 2
DoEvents
Loop Until img1.Left = 120
'move top left to bottom left
Do
img1.Top = img1.Top + 2
DoEvents
Loop Until img1.Top = 5640
'go through the loops again when the image
'has reached the start position
If img1.Left = 120 Then GoTo continue
Experiment and above all have FUN
GRAHAM
-
Apr 1st, 2000, 05:42 PM
#3
Thread Starter
Junior Member
cheers graham! that was quite a help..
is there any way i can make the image move manually? so like when you press left the image moves left one?
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
|