Windows形式的动画 [英] Animation in windows form
本文介绍了Windows形式的动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个需要动画的画框,即移动和更改图像.
Hi,
I''m having a picturebox which I need to animate, i.e. to move and change the image.
Imports System
Imports System.Drawing
Public Class Form1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Static x As Integer = 5
Static y As Integer = 0
Static flip As Integer = False
If y Mod 2 = 0 Then
Me.PictureBox1.Image = My.Resources.Resource1.Bird_l
Else
Me.PictureBox1.Image = My.Resources.Resource1.bird_r
End If
If Me.PictureBox1.Left >= 500 Then
x = -5
flip = True
ElseIf Me.PictureBox1.Left <= 0 Then
x = 5
flip = False
End If
If flip = True Then
Me.PictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipX)
End If
Me.PictureBox1.Left = Me.PictureBox1.Left + x
y += 1
End Sub
End Class
运行时,该行显示错误:-
While running it''s showing error in the line:-
Me.PictureBox1.Image = My.Resources.Resource1.bird_r
-参数无效"
为什么会出现错误?
Thanx
- "Parameter Not Valid"
Why is the error?
Thanx
推荐答案
您需要检查如何添加资源My.Resources.Resource1.Bird_l
和My.Resources.Resource1.Bird_r
,因为使用我自己的图像对其进行测试后,该代码对我有用.智能感知是否表明这些资源的声明是错误的?将图像添加到资源文件时,我使用My.Resources.myImageName.
You need to check how you have added the resourcesMy.Resources.Resource1.Bird_l
andMy.Resources.Resource1.Bird_r
as the code works for me after testing it with my own images. Does intellisense give any indication that the declaration of these resources is wrong? When I add an image to a resource file I use My.Resources.myImageName.
这篇关于Windows形式的动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文