如何使球像滚动一样动画 还有踢球者 如何为足球运动员制作动画以及如何同步它们以便看起来他正在踢球

How to make the ball animate like its rolling And also the kicker how to animate the soccer player and how to sync them so it looks like he is kicking

该计划有 3 种形式 表格 1 代码

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Form2.Show()
        Form2.Location = New Point(485, 100)
        Form2.Width = 400
        Form2.Height = 300

        Form3.Show()
        Form3.Location = New Point(860, 100)
        Form3.Width = 400
        Form3.Height = 300

        Me.Location = New Point(100, 100)
        Me.Width = 400
        Me.Height = 300

        Me.Location = New Point(100, 100)
        Me.Width = 400
        Me.Height = 300
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        OS1.Left = OS1.Left + 3
        Form2.OS2.Visible = False
        Form3.OS3.Visible = False
        If OS1.Left >= 350 Then
            Timer1.Stop()
            OS1.Visible = False
            Form2.OS2.Visible = True
            Form2.Timer1.Start()
        End If
    End Sub
End Class

表格 2 代码

Public Class Form2

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        OS2.Left = OS2.Left + 3
        If OS2.Left >= 350 Then
            Timer1.Stop()
            OS2.Visible = False
            Form3.OS3.Visible = True
            Form3.Timer1.Start()
        End If
    End Sub
End Class

表格 3 代码

Public Class Form3

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        OS3.Left = OS3.Left + 3
        If OS3.Left >= 200 Then
            Timer1.Stop()
            Timer2.Start()
        End If
    End Sub
End Class

enter image description here

我还有一个视频 link 介绍了它目前的工作原理 link: https://youtu.be/JgBN4Uxdm_w 我只想让精灵动画化我的资源中有 12 张足球图片和 5 张球员图片我只想让它们动画化。

您可以分别为OS1、OS2、OS3设置动画功能。 然后在窗体中直接传一个参数,让动画连贯。 但是用图片做动画是非常低效的。 这是基于您的代码实现的一种相当粗略的方法。

表格 1

    Public Dim mv As Integer = 1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Form2.Show()
    Form2.Location = New Point(485, 100)
    Form2.Width = 400
    Form2.Height = 300
    Form3.Show()
    Form3.Location = New Point(860, 100)
    Form3.Width = 400
    Form3.Height = 300

    Me.Location = New Point(100, 100)
    Me.Width = 400
    Me.Height = 300

    Me.Location = New Point(100, 100)
    Me.Width = 400
    Me.Height = 300
    Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    OS1.Left = OS1.Left + 3
    Form2.OS2.Visible = False
    Form3.OS3.Visible = False
    If OS1.Left >= 350 Then
        Timer1.Stop()
        OS1.Visible = False
        Form2.mv = Me.mv
        Form2.OS2.Visible = True
        Form2.Timer1.Start()
    End If
End Sub
Private Sub animate()
    If mv = 1 Then
        OS1.Image = Image.FromFile("football1")
        mv = 2
    ElseIf mv = 2 Then
        OS1.Image = Image.FromFile("football2")
        mv = 3
    ElseIf mv = 3 Then
        OS1.Image = Image.FromFile("football3")
        mv = 4
    ElseIf mv = 4 Then
        OS1.Image = Image.FromFile("football4")
        mv = 1
    End If
End Sub

Form2

Public Dim mv As Integer = 1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    OS2.Left = OS2.Left + 3
    OS2.Visible = True
    If OS2.Left >= 350 Then
        Timer1.Stop()
        OS2.Visible = False
        Form3.mv = Me.mv
        Form3.OS3.Visible = True
        Form3.Timer1.Start()
    End If
End Sub
Private Sub animate()
    If mv = 1 Then
        OS2.Image = Image.FromFile("football1")
        mv = 2
    ElseIf mv = 2 Then
        OS2.Image = Image.FromFile("football2")
        mv = 3
    ElseIf mv = 3 Then
        OS2.Image = Image.FromFile("football3")
        mv = 4
    ElseIf mv = 4 Then
        OS2.Image = Image.FromFile("football4")
        mv = 1
    End If
End Sub

Form3

Public Dim mv As Integer = 1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    OS3.Left = OS3.Left + 3
    OS3.Visible = True
    If OS3.Left >= 350 Then
        Timer1.Stop()
        OS3.Visible = False
    End If
End Sub
Private Sub animate()
    If mv = 1 Then
        OS3.Image = Image.FromFile("football1")
        mv = 2
    ElseIf mv = 2 Then
        OS3.Image = Image.FromFile("football2")
        mv = 3
    ElseIf mv = 3 Then
        OS3.Image = Image.FromFile("football3")
        mv = 4
    ElseIf mv = 4 Then
        OS3.Image = Image.FromFile("football4")
        mv = 1
    End If
End Sub

这是我的表格 1 代码 Public Class Form1

Public mv As Integer = 1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
    Form2.Show()
    Form2.Location = New Point(485, 100)
    Form2.Width = 400
    Form2.Height = 300
    Form3.Show()
    Form3.Location = New Point(860, 100)
    Form3.Width = 400
    Form3.Height = 300

    Me.Location = New Point(100, 100)
    Me.Width = 400
    Me.Height = 300

    Me.Location = New Point(100, 100)
    Me.Width = 400
    Me.Height = 300
    Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    OS1.Left = OS1.Left + 3
    Form2.OS2.Visible = False
    Form3.OS3.Visible = False
    If OS1.Left >= 350 Then
        Timer1.Stop()
        OS1.Visible = False
        Form2.mv = Me.mv
        Form2.OS2.Visible = True
        Form2.Timer1.Start()
    End If
End Sub
Private Sub animate()
    If mv = 1 Then
        OS1.Image = Image.FromFile("football1.png")
        mv = 2
    ElseIf mv = 2 Then
        OS1.Image = Image.FromFile("football2.png")
        mv = 3
    ElseIf mv = 3 Then
        OS1.Image = Image.FromFile("football3.png")
        mv = 4
    ElseIf mv = 4 Then
        OS1.Image = Image.FromFile("football4.png")
        mv = 1
    End If
End Sub

结束Class

表格 2 代码 Public Class Form2

Public mv As Integer = 1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    OS2.Left = OS2.Left + 3
    OS2.Visible = True
    Form3.OS3.Visible = False
    If OS2.Left >= 350 Then
        Timer1.Stop()
        OS2.Visible = False
        Form3.mv = Me.mv
        Form3.OS3.Visible = True
        Form3.Timer1.Start()
    End If
End Sub
Private Sub animate()
    If mv = 1 Then
        OS2.Image = Image.FromFile("football1.png")
        mv = 2
    ElseIf mv = 2 Then
        OS2.Image = Image.FromFile("football2.png")
        mv = 3
    ElseIf mv = 3 Then
        OS2.Image = Image.FromFile("football3.png")
        mv = 4
    ElseIf mv = 4 Then
        OS2.Image = Image.FromFile("football4.png")
        mv = 1
    End If
End Sub

结束Class

表格 3 代码 Public Class Form3

Public mv As Integer = 1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    OS3.Left = OS3.Left + 3
    OS3.Visible = True
    If OS3.Left >= 350 Then
        Timer1.Stop()
        OS3.Visible = False
    End If
End Sub
Private Sub animate()
    If mv = 1 Then
        OS3.Image = Image.FromFile("football1.png")
        mv = 2
    ElseIf mv = 2 Then
        OS3.Image = Image.FromFile("football2.png")
        mv = 3
    ElseIf mv = 3 Then
        OS3.Image = Image.FromFile("football3.png")
        mv = 4
    ElseIf mv = 4 Then
        OS3.Image = Image.FromFile("football4.png")
        mv = 1
    End If
End Sub

结束Class

错误信息:

未处理 FileNotfoundException C:\Users921\documents\visual工作室2010\Projects\ptptpttptptptpptptpt\ptptpttptptptptpptptpt\bin\Debugsoccerball1

enter image description here

enter image description here