Vb.net 图片框中的图像在按下键时不旋转

Vb.net 图片框中的图像在按下键时不旋转,vb.net,Vb.net,我正在做一个停车游戏。我正在使用箭头键移动它,但当按下向下键时,图片框不会向下移动。此外,当按下向右键或向上键时,图片框不会停止。我还想在向右或向左移动时旋转汽车。我尝试了,但无法 Private Sub Timerdiagonalright_Tick(sender As Object, e As EventArgs) Handles Timerdiagonalright.Tick RotateImage(pbcar1.Image, 20) End Sub Private Fu

我正在做一个停车游戏。我正在使用箭头键移动它,但当按下向下键时,图片框不会向下移动。此外,当按下向右键或向上键时,图片框不会停止。我还想在向右或向左移动时旋转汽车。我尝试了,但无法

 Private Sub Timerdiagonalright_Tick(sender As Object, e As EventArgs) Handles Timerdiagonalright.Tick
    RotateImage(pbcar1.Image, 20)

End Sub



Private Function RotateImage(img As Image, angle As Single) As Bitmap
    ' the calling code is responsible for (and must) 
    ' disposing of the bitmap returned

    Dim retBMP As New Bitmap(img.Width, img.Height)
    retBMP.SetResolution(img.HorizontalResolution, img.VerticalResolution)

    Using g = Graphics.FromImage(retBMP)
        ' rotate aroung the center of the image
        g.TranslateTransform(img.Width \ 2, img.Height \ 2)

        'rotate
        g.RotateTransform(angle)

        g.TranslateTransform(-img.Width \ 2, -img.Height \ 2)

        'draw image to the bitmap
        g.DrawImage(img, New PointF(0, 0))

        Return retBMP
    End Using
End Function

如果图像已加载到PictureBox,则可以使用

PictureBox.Image.RotateFlip(RotateFlipType)
旋转图像


请注意,这不是制作动画图形的有效方法;为了提高移动控件的性能,请考虑在SunDayStay/RealDayAudio和NeXupUp/EndPosial./P>阅读。今天肯定有很多来自毛里求斯的学生遇到了麻烦。请阅读并接受请帮助我,我已经尽力了请阅读并接受。RotateFlipType不是有效位置将鼠标放在它上,然后按F1@JimmySmith是的,我放了一个断点,它将它,me.height的值为366,x和y的值为191187。你的标题与你在评论中谈论的问题不再匹配,这降低了有人回答的机会。我不确定你为什么要在计时器上显示它-它可能会在中途倒转