【发布时间】:2015-01-17 17:09:27
【问题描述】:
我目前正在使用 Visual Basic 2010 Express 制作迷宫游戏。我目前正在研究迷宫中角色的键盘控件。我成功了……有点。我可以使用以下代码让 Picturebox 对象移动:
Private Sub Lvl1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Select e.KeyCode
Case Keys.W
Player.Location = New Point(Player.Location.X, Player.Location.Y - 2)
Case Keys.S
Player.Location = New Point(Player.Location.X, Player.Location.Y + 2)
Case Keys.D
Player.Location = New Point(Player.Location.X + 2, Player.Location.Y)
Case Keys.A
Player.Location = New Point(Player.Location.X - 2, Player.Location.Y)
End Select
End Sub
话虽如此,我对结果不是很满意。当我运行该应用程序时,Picturebox 移动 非常 缓慢并且 verrrryyyy 抖动。最重要的是,它不能沿对角线方向移动。我认为这是一款非常不实用的游戏,因为用户可能会对类似蛞蝓的移动速度感到非常厌烦。有什么方法可以简单地对 Picturebox 进行编程,使其以 2 个像素的增量快速移动并且平滑(即在改变方向之前没有延迟)?谢谢!
【问题讨论】: