我刚刚开始在C#/ XNA中编码 我在XNA中制作了一个非常简单的小程序,它是一个绘制的矩形,内有3个随机生成的球, 球在自己的类中定义和我已经使用以下用鼠标点击添加2D精灵
INT ballCount = 3本教程生成 http://www.bluerosegames.com/brg/xna101.aspx
球;
,什么我想要做的就是让这么一个鼠标点击将增加1整型,加入另一球到屏幕
我的代码看起来是这样,但我不知道这是否是正确的/可能
mouseStateCurrent = Mouse.GetState();
if (mouseStateCurrent.LeftButton == ButtonState.Pressed &&
mouseStatePrevious.LeftButton == ButtonState.Released)
{
ballCount = ballCount+1;
}
mouseStatePrevious = mouseStateCurrent;
任何帮助的建议将是有益的:)
我使用一个代码来绘制球已经看起来像这样
spriteBatch.Begin();
spriteBatch.Draw(debugColor, TextBox, Color.White);
spriteBatch.Draw(background, backgroundRectangle, Color.White);
foreach (BouncingBall ball in balls)
{
ball.Draw(spriteBatch);
}
spriteBatch.End();
base.Draw(gameTime);
是否可以编辑这个来获得“点击添加球”效果?