C# Can';我不想画圈
我将每个对象的绘图保存在一个单独的类中,然后在主绘图类中调用它。不管怎样,我需要把这个循环弄对,因为我要用它做很多模型 它将为我画出第一次,但在那之后,xCoord似乎没有为我移动,否则有一些其他的循环错误。没有语法错误之类的,程序运行,只是不是我想要的方式 任何帮助都将不胜感激C# Can';我不想画圈,c#,xna,C#,Xna,我将每个对象的绘图保存在一个单独的类中,然后在主绘图类中调用它。不管怎样,我需要把这个循环弄对,因为我要用它做很多模型 它将为我画出第一次,但在那之后,xCoord似乎没有为我移动,否则有一些其他的循环错误。没有语法错误之类的,程序运行,只是不是我想要的方式 任何帮助都将不胜感激 /// <summary> /// Draws the bottom platform (ground) /// </summary> public void D
/// <summary>
/// Draws the bottom platform (ground)
/// </summary>
public void DrawBottomPlatform()
{
int xCoord = 0;
int yCoord = (screenHeight / 10) * 9;
int width = screenWidth / 20;
int height = screenHeight / 20;
Rectangle bottomRectangle = new Rectangle(xCoord, yCoord, width, height);
int i = 0;
while (i <= 5)
{
spriteBatch.Draw(grassTexture, bottomRectangle, Color.White);
xCoord += bottomRectangle.Width;
i += 1;
}
}
//
///绘制底部平台(地面)
///
公共平台()
{
int xCoord=0;
int yCoord=(屏幕高度/10)*9;
内部宽度=屏幕宽度/20;
内部高度=屏幕高度/20;
矩形底部矩形=新矩形(xCoord、yCoord、宽度、高度);
int i=0;
虽然(i您从不使用更新后的xCoord
,但循环开始后,该值将被忽略。在每次迭代时移动矩形,而不是更新xCoord
:
int i = 0;
while (i <= 5)
{
spriteBatch.Draw(grassTexture, bottomRectangle, Color.White);
bottomRectangle.X += bottomRectangle.Width;
i += 1;
}
inti=0;
虽然(i您从不使用更新后的xCoord
,但循环开始后,该值将被忽略。在每次迭代时移动矩形,而不是更新xCoord
:
int i = 0;
while (i <= 5)
{
spriteBatch.Draw(grassTexture, bottomRectangle, Color.White);
bottomRectangle.X += bottomRectangle.Width;
i += 1;
}
inti=0;
while(我认为这是一个非常糟糕的标题。为什么你会期望while循环来绘制一些东西?这不是图形上下文对象(或者在本例中是SpriteBatch实例)的功能吗是为?这个标题非常糟糕。为什么你会期望一个while循环来绘制一些东西?这不是图形上下文对象(或者在本例中是SpriteBatch实例)的用途吗?