Cameron161
New member
- Joined
- Apr 29, 2015
- Messages
- 1
- Programming Experience
- Beginner
*EDIT*: Title meant to say "using" instead of "user"
I need some help with a problem that I cannot get a smooth animation for when the ball changes position and a line trailing it, when a timer ticks
Here is my code:
Dim Count As Double
Dim Speed As Double
Dim AngleIn As Double
Dim AngleOut As Double
Dim Accl As Double
Dim VertV As Double
Dim HorV As Double
these are declared globally
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim canvas As New ShapeContainer
Dim theLine As New LineShape
'' Set the form as the parent of the ShapeContainer.
canvas.Parent = Me
'' Set the ShapeContainer as the parent of the LineShape.
theLine.Parent = canvas
'' Set the starting and ending coordinates for the line.
theLine.StartPoint = New System.Drawing.Point(Ball.Left, Ball.Top)
Count = Count + 0.1
TimeTextBox.Text = Count
BallLeftTextBox.Text = Ball.Left
BallTopTextBox.Text = Ball.Top
VertV = (Speed * Sin(AngleOut)) + (AcclTextBox.Text * TimeTextBox.Text)
VertVelocityTextBox.Text = VertV
HorV = Speed * Cos(AngleOut)
HorVelocityTextBox.Text = HorV
Ball.Left = InitialBallLeftTextBox.Text + ((Speed * Cos(AngleOut)) * Count)
Ball.Top = InitialBallTopTextBox.Text - ((Speed * Sin(AngleOut) * Count) + ((0.5 * Accl) * Count ^ 2))
theLine.EndPoint = New System.Drawing.Point(Ball.Left, Ball.Top)
VertDisplacementTextBox.Text = InitialBallTopTextBox.Text - BallTopTextBox.Text
HorDisplacementTextBox.Text = BallLeftTextBox.Text - InitialBallLeftTextBox.Text
If Ball.Top >= 572 And Count > 0.1 Then
Timer1.Stop()
Else
End If
End Sub
When I just have the ball changing position the stuttering is not as bad
but when I have the line trailing the path of the ball, the animation flashes all the time and this gets progressively worse the longer the Timer is on for
Is there a solution to make it smooth without the stuttering
Help would be appreciated
I need some help with a problem that I cannot get a smooth animation for when the ball changes position and a line trailing it, when a timer ticks
Here is my code:
Dim Count As Double
Dim Speed As Double
Dim AngleIn As Double
Dim AngleOut As Double
Dim Accl As Double
Dim VertV As Double
Dim HorV As Double
these are declared globally
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim canvas As New ShapeContainer
Dim theLine As New LineShape
'' Set the form as the parent of the ShapeContainer.
canvas.Parent = Me
'' Set the ShapeContainer as the parent of the LineShape.
theLine.Parent = canvas
'' Set the starting and ending coordinates for the line.
theLine.StartPoint = New System.Drawing.Point(Ball.Left, Ball.Top)
Count = Count + 0.1
TimeTextBox.Text = Count
BallLeftTextBox.Text = Ball.Left
BallTopTextBox.Text = Ball.Top
VertV = (Speed * Sin(AngleOut)) + (AcclTextBox.Text * TimeTextBox.Text)
VertVelocityTextBox.Text = VertV
HorV = Speed * Cos(AngleOut)
HorVelocityTextBox.Text = HorV
Ball.Left = InitialBallLeftTextBox.Text + ((Speed * Cos(AngleOut)) * Count)
Ball.Top = InitialBallTopTextBox.Text - ((Speed * Sin(AngleOut) * Count) + ((0.5 * Accl) * Count ^ 2))
theLine.EndPoint = New System.Drawing.Point(Ball.Left, Ball.Top)
VertDisplacementTextBox.Text = InitialBallTopTextBox.Text - BallTopTextBox.Text
HorDisplacementTextBox.Text = BallLeftTextBox.Text - InitialBallLeftTextBox.Text
If Ball.Top >= 572 And Count > 0.1 Then
Timer1.Stop()
Else
End If
End Sub
When I just have the ball changing position the stuttering is not as bad
but when I have the line trailing the path of the ball, the animation flashes all the time and this gets progressively worse the longer the Timer is on for
Is there a solution to make it smooth without the stuttering
Help would be appreciated