简体   繁体   English

C#Windows Forms Platform游戏,在向右/向左移动时跳跃被取消并且看上去不流畅

[英]C# Windows Forms Platform Game, Jumping while moving to the right/left is getting canceled and doesnt look smooth

I am working on a Jump and Run and got the Problem if I'm walking to the right/left while holding the (A/D-Key) and then press W to Jump, the moving process to the left/right is getting canceled and I have to repress the A/D Button to continue walking. 我正在进行跳跃和奔跑,如果在按住(A / D键)的同时向右/向左行走,然后按W进行跳跃,则会出现问题,取消向左/向右移动的过程而且我必须按下A / D按钮才能继续行走。 Do you know any solution for it? 您知道解决方案吗?

Another question is if somebody knows a good Website for some animated Characters as .GIF for moving right, standing still, moving left and for jumping Source-Code: 另一个问题是,是否有人知道一个不错的网站来制作一些动画人物,如.GIF,以便向右移动,站立不动,向左移动并跳跃源代码:

private void Tutorial_KeyDown(object sender, KeyEventArgs e){
if (e.KeyCode == Keys.W)
{
 b_Jump = true;
 Movement.Enabled = true;
}
else if (e.KeyCode == Keys.A || e.KeyCode == Keys.Left)
{
 b_Left = true;
 Movement.Enabled = true;
}
else if (e.KeyCode == Keys.D || e.KeyCode == Keys.Right)
{
 b_Right = true;
 Movement.Enabled = true;
}

} }

private void Movement_Tick(object sender, EventArgs e)

{ {

if(b_Left == true)
{
 Spieler.Left -= i_Geschwindigkeit;
 Movement.Enabled = false;
}
else if (b_Right == true)
{
 Spieler.Left += i_Geschwindigkeit;
 Movement.Enabled = false;
}

else if (b_Jump == true)
{
 Sprunganstieg.Enabled = true;
 Sprungabfall.Enabled = true; <- Just makes the Playermodel reach the Ground 
 b_Jump = false;                 after a small delay

}

} }

Windows Forms is not the right tool for game development. Windows窗体不是游戏开发的正确工具。 You can use it for purely turnbased games with single or hotseat multiplayer within limits. 您可以将其用于在限制范围内具有单人或双座位多人游戏的纯粹回合制游戏。 The old Solitaire is at or ever close to the maximum possible. 旧的纸牌已经达到或接近最大可能。 Latest when you try to do complex animation, you run into issues like these. 最近,当您尝试制作复杂的动画时,会遇到类似这样的问题。

If you want to do proper Game Development, XNA is the somewhat dated tool for the .NET Framework. 如果您想进行适当的游戏开发,则XNA是.NET Framework的过时工具。 Otherwise you should look wich of those options your target framework supports: https://www.microsoft.com/net/learn/apps/gaming But in the end, anything that has a game loop should work. 否则,您应该看一下目标框架支持的那些选项: https : //www.microsoft.com/net/learn/apps/gaming但最后,任何具有游戏循环的东西都应该起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM