我正在XNA制作2D塔防游戏,对于我的敌人,我需要将他们的起始坐标传递到Game1类,这样我就可以在正确的位置绘制它们。但是,由于Game1是一个预先制作的类,我认为我不能传递它们的引用。有没有办法通过引用传递变量而不修改类的参数(我认为这是括号中的东西)。 只是要求澄清。谢谢!!! (Ant是敌人,而startplace是在ant的基类中定义的)
P.S BUg.startplace不起作用
代码:
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
Content.RootDirectory = "Content";
background = Content.Load<Texture2D>("background");
Texture2D AntTexture = Content.Load<Texture2D>("ant");
//ant1 is already made I'm just setting it to something here
ant1 = new Ant(AntTexture, Bug.startplace, 100, 10, 0.5f);
Texture2D BlueberryBushTexture = Content.Load<Texture2D>("blueberrybush");
player = new Player(level, BlueberryBushTexture);
// TODO: use this.Content to load your game content here
}
答案 0 :(得分:0)
所以我意识到,起始变量实际上并不重要,因为绘图是在以后完成的。我混淆了draw()和LoadContent()方法。抱歉这个大脑翻牌!!!