它说
"Method must have a return type"
每当我尝试调试它时。
我不知道如何修复这个类
这是一个用 c# 编码的 2d 游戏的播放器类
public class player
{
public float moveSpeed;
public Vector2 position;
public Texture2D texture;
//default constructer
public Player(Texture2D tex, Vector2 startPos)
{
position = startPos;
texture = tex;
moveSpeed = 5.0f;
}
public void Update(GameTime gameTime)
{
//------------------------------------------
//check for keyboard input(keyboard IF statements)
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(texture, position, Color.White);
}
}
最佳答案
您的类是 player
但构造函数是 Player
,因为它们不同,所以期望 Player
是方法而不是构造函数
把类名改成Player
就可以了
关于c# - Visual Studio 说 "Method must have a return type",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22739932/