[英]Can someone tell me why this doesn't work? C# XNA
So I made this method for spawning mobs with a time delay in between, the problem is that the condition goes through but it doesn't want to access what's inside. 因此,我使用了这种方法来生成生物,它们之间有一定的时间延迟,问题是条件可以通过,但它不想访问内部的信息。
public void CreateMonsterWave(GameTime gameTime)
{
spawnDelay += (float)gameTime.ElapsedGameTime.TotalSeconds;
if (spawnDelay >= 2f && creepAmountOut < monsterWave.Length)
{
spawnDelay = 0f;
monsterWave[creepAmountOut] = new WaveMonster(monsterHp, monsterDamage, monsterTex, waveStartPos, path1);
creepAmountOut++;
}
}
//In LoadContent
monsterWave = new WaveMonster[8];
I'm pretty new to coding so it feels like I'm missing something fundamental... 我对编码还很陌生,所以感觉好像我缺少一些基本知识...
I would check the condition of your if statement ensuring that the "spawnDelay" is greater or equal to 2f and the "creepAmountOut" is less than the "monsterWave.length". 我将检查您的if语句的条件,以确保“ spawnDelay”大于或等于2f并且“ creepAmountOut”小于“ monsterWave.length”。 You can use a messagebox or something before the if statement to display this data to ensure that everything evaluates to a true condition of that if statement.
您可以在if语句之前使用消息框或其他内容来显示此数据,以确保所有内容均符合该if语句的真实条件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.