【发布时间】:2021-12-26 05:57:25
【问题描述】:
我正在尝试使用 Monogame 和 RogueSharp 在 C# 中制作 rougelike。
这是我在 Draw() 中的一些代码
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
_spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
int sizeOfSprites = 64;
float scale = .25f;
foreach (Cell cell in _map.GetAllCells())
{
// error in the line below
Microsoft.Xna.Framework.Rectangle position = new Microsoft.Xna.Framework.Rectangle(cell.X * sizeOfSprites * scale, cell.Y * sizeOfSprites * scale);
if (cell.IsWalkable)
{
_spriteBatch.Draw(floorSprite, position, null, Color.White, 0f, new Vector2(scale, scale), 0.0f, 0f);
}
else
{
_spriteBatch.Draw(wallSprite, position, null, Color.White, 0f, new Vector2(scale, scale), 0.0f, 0f);
}
}
_spriteBatch.End();
base.Draw(gameTime);
}
返回:
参数 2:无法从 'float' 转换为 'Microsoft.Xna.Framework.Point'
参数 1:无法从 'float' 转换为 'Microsoft.Xna.Framework.Point'
【问题讨论】: