|
-
Nov 26th, 2008, 10:12 AM
#1
Thread Starter
Hyperactive Member
-
Nov 26th, 2008, 12:15 PM
#2
Thread Starter
Hyperactive Member
-
Nov 26th, 2008, 12:57 PM
#3
Re: [2005] Move Towards Mouse
are you looking for animation here?
-
Nov 26th, 2008, 01:08 PM
#4
Re: [2005] Move Towards Mouse
Try this:
Put a timer control and a picturebox on the form and this code:
You can alter the MoveUnits and the Timer1.Interval to get the desired speed and tolerence.
vb.net Code:
Public Class Form1 Const MoveUnits As Integer = 5 Dim mouseX, mouseY As Integer Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Timer1.Interval = 5 Timer1.Enabled = True End Sub Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove mouseX = e.X mouseY = e.Y End Sub Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim nX, nY As Integer nX = PictureBox1.Left + PictureBox1.Width \ 2 nY = PictureBox1.Top + PictureBox1.Height \ 2 If mouseX > nX Then nX += MoveUnits Else nX -= MoveUnits If mouseY > nY Then nY += MoveUnits Else nY -= MoveUnits If Math.Abs(mouseX - nX) > MoveUnits Then PictureBox1.Left = nX - PictureBox1.Width \ 2 If Math.Abs(mouseY - nY) > MoveUnits Then PictureBox1.Top = nY - PictureBox1.Height \ 2 End Sub End Class
Pradeep
-
Nov 26th, 2008, 01:32 PM
#5
Thread Starter
Hyperactive Member
-
Nov 26th, 2008, 02:20 PM
#6
Re: [2005] Move Towards Mouse
I can't understand what you are trying to achieve.
Is the point of meeting of blue and red lines the current mouse position?
Should those lines always be perpendicular to each other?
what is the circle (and the rectangle which I assume is the picturebox) in that drawing?
-
Nov 26th, 2008, 02:28 PM
#7
Thread Starter
Hyperactive Member
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
|