use*_*229 8 c# methods spritebatch
它说
"方法必须具有返回类型"
每当我尝试调试它.
我不知道怎么修这门课
这是ac#编码的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);
}
}
Run Code Online (Sandbox Code Playgroud)
您的班级名称是player小写的.当编译器找到类Player(大写)的构造函数时,它认为它是一个Player没有指定返回类型的方法.
所以只需将您的类重命名为大写Player.C#是区分大小写的,所以player和Player是两个不同的东西.
| 归档时间: |
|
| 查看次数: |
45695 次 |
| 最近记录: |