animation?
-
Please tell me there is a better way to make a pacman like shape move across my form...
Public Class Form1
Dim formSurface As Graphics = Me.CreateGraphics
Dim intLoop As Integer = 0Private Sub btnStart\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click tmrMove.Enabled = True End Sub Private Sub tmrMove\_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrMove.Tick formSurface.Clear(Color.Black) Select Case intLoop Case 0 formSurface.DrawImage(My.Resources.pacmanopen, 10, 75) Case 1 formSurface.DrawImage(My.Resources.pacmanopen, 11, 75) Case 2 formSurface.DrawImage(My.Resources.pacmanopen, 12, 75) Case 3 formSurface.DrawImage(My.Resources.pacmanopen, 13, 75) Case 4 formSurface.DrawImage(My.Resources.pacmanopen, 14, 75) Case 5 formSurface.DrawImage(My.Resources.pacmanopen, 15, 75) End Select intLoop += 1 End Sub
End Class
Could I possibly do something like...
Case 0 to 100 formSurface.DrawImage(My.Resources.pacmanopen, intX, 75)
and then add 1 to intX each time? I'm open to any ideas...
-
Please tell me there is a better way to make a pacman like shape move across my form...
Public Class Form1
Dim formSurface As Graphics = Me.CreateGraphics
Dim intLoop As Integer = 0Private Sub btnStart\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click tmrMove.Enabled = True End Sub Private Sub tmrMove\_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrMove.Tick formSurface.Clear(Color.Black) Select Case intLoop Case 0 formSurface.DrawImage(My.Resources.pacmanopen, 10, 75) Case 1 formSurface.DrawImage(My.Resources.pacmanopen, 11, 75) Case 2 formSurface.DrawImage(My.Resources.pacmanopen, 12, 75) Case 3 formSurface.DrawImage(My.Resources.pacmanopen, 13, 75) Case 4 formSurface.DrawImage(My.Resources.pacmanopen, 14, 75) Case 5 formSurface.DrawImage(My.Resources.pacmanopen, 15, 75) End Select intLoop += 1 End Sub
End Class
Could I possibly do something like...
Case 0 to 100 formSurface.DrawImage(My.Resources.pacmanopen, intX, 75)
and then add 1 to intX each time? I'm open to any ideas...
yes, you should keep your shape's location in some variable(s). And paint only in the Paint handler. This article[^] will give you the principles and an example; it is a C# example, but that only constitutes a different syntax, it does not affect the principles. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
Please tell me there is a better way to make a pacman like shape move across my form...
Public Class Form1
Dim formSurface As Graphics = Me.CreateGraphics
Dim intLoop As Integer = 0Private Sub btnStart\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click tmrMove.Enabled = True End Sub Private Sub tmrMove\_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrMove.Tick formSurface.Clear(Color.Black) Select Case intLoop Case 0 formSurface.DrawImage(My.Resources.pacmanopen, 10, 75) Case 1 formSurface.DrawImage(My.Resources.pacmanopen, 11, 75) Case 2 formSurface.DrawImage(My.Resources.pacmanopen, 12, 75) Case 3 formSurface.DrawImage(My.Resources.pacmanopen, 13, 75) Case 4 formSurface.DrawImage(My.Resources.pacmanopen, 14, 75) Case 5 formSurface.DrawImage(My.Resources.pacmanopen, 15, 75) End Select intLoop += 1 End Sub
End Class
Could I possibly do something like...
Case 0 to 100 formSurface.DrawImage(My.Resources.pacmanopen, intX, 75)
and then add 1 to intX each time? I'm open to any ideas...
The whole approach of using winforms is doomed to failure. You should use XNA, or perhaps WPF, something DirectX based.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
The whole approach of using winforms is doomed to failure. You should use XNA, or perhaps WPF, something DirectX based.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
yes, you should keep your shape's location in some variable(s). And paint only in the Paint handler. This article[^] will give you the principles and an example; it is a C# example, but that only constitutes a different syntax, it does not affect the principles. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
The whole approach of using winforms is doomed to failure. You should use XNA, or perhaps WPF, something DirectX based.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.