|
-
Mar 13th, 2001, 11:47 PM
#1
Thread Starter
Fanatic Member
I have the tip of a gun showing in frame1 in the
bottom - center.
I want a laser beam to follow the cursor from the point of the gun. Any Suggestions??
-
Mar 14th, 2001, 03:32 AM
#2
PowerPoster
Not a lot of information to go on there...
If you calculate the offset of the tip of the gun, from the top left of the control it's in, this will give you a start point for where to place your laser beam image.
e.g.
If the control holding your gun image is 40 x 40 and the tip of the gun is at bottom of the control in the middle, then the start point for the laser graphic (or effect or whatever) would be
guncontrol.left+20
guncontrol.top+40
This help?
Gentile or Jew,
O you who turn the wheel and look to windward,
Consider Phlebas, who was once handsome and tall as you...
-
Mar 14th, 2001, 03:33 AM
#3
PowerPoster
Forgot to add,
The end point for the laser would be the mouse co-ordinates...
Gentile or Jew,
O you who turn the wheel and look to windward,
Consider Phlebas, who was once handsome and tall as you...
-
Mar 14th, 2001, 11:26 AM
#4
Are you working in 2D, or 3D? If you want to work in 2D, it is simple. Use the line method to draw a Line from GunPoint.X and .Y to CursorPos.X and .Y:
Code:
Declare blah blah blah GetCursorPos blah()
'// dont copy that line, use the API viewer
Private Type POINTAPI
X As Long
Y As Long
End Type
Sub DrawMeLine()
Dim CursorPos as POINTAPI
CursorPos = GetCursorPos
Canvas.Line(GunPoint.X, GunPoint.Y)-(CursorPos.X, CursorPos.Y) '//where Canvas is a valid PictureBox, Form, or (though i doubt youll use this one) Printer Object
'//Do other drawing stuff here
End Sub
That will do the trick, with a bit of simple modification(The GunPoint variable, for example).
Z.
[edit]
The syntax for GetCursorPos should be:
Code:
dim retval as long
retval = GetCursorPos(CursorPos)
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
|