1、画几个齿轮,大小随意,齿数对应,并按咬合关系调整好位置
2、分别复制三、五个(因为齿轮的齿间距是相同的,所以动画起来,仅需几帧即可实现360度旋转效果,但帧数越多,动画越细腻),在每层上调整角度,使其与下一个齿距咬合,每一个咬合做一个图层。
3、打开动画面板,将图层转换为帧,设置时间,导出动画。
两个image,不能有其它可以获得焦点的控件,如果要加控件就要把控件的keydown事件映射到窗体的keydown事件上。Option Explicit
Const VK_LEFT As Long = &H25
Const VK_UP As Long = &H26
Const VK_RIGHT As Long = &H27
Const VK_DOWN As Long = &H28
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case VK_LEFT
MoveImage -50
Case VK_UP
MoveImage , -50
Case VK_RIGHT
MoveImage 50
Case VK_DOWN
MoveImage , 50
End Select
End Sub
Private Sub MoveImage(Optional x As Integer = 0, Optional y As Integer = 0)
With Image1
.Left = .Left + x
.Top = .Top + y
If .Left <0 Then .Left = 0
If .Left >Me.ScaleWidth - .Width Then .Left = Me.ScaleWidth - .Width
If .Top <0 Then .Top = 0
If .Top >Me.ScaleHeight - .Height Then .Top = Me.ScaleHeight - .Height
If .Left + .Width >Image2.Left And .Left <Image2.Left + Image2.Width And .Top + .Height >Image2.Top And .Top <Image2.Top + Image2.Width Then
MsgBox "碰撞了"
End If
End With
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)