简体   繁体   English

有人可以告诉我为什么这行不通吗? C#XNA

[英]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.

相关问题 有人能告诉我为什么这个lambda排序表达式不起作用? - Can someone tell me why this lambda sort expression doesn't work? 有人可以告诉我为什么我的标题没有显示asp.net C# - Can someone tell me why my header isn't showing up asp.net c# 有人可以告诉我为什么这简单的C#代码不起作用,涉及从自身内部递归调用方法以获得根类别ID。 - Can someone tell me why this simple bit of c# code won't work, involves recursively calling method from within itself to get the root category ID 有人可以告诉我如何在C#上修复此错误 - Can someone tell me how to fix this error on C# MS Visual Studio C#-有人可以向我解释为什么我的代码不起作用以及如何使它起作用吗? - MS Visual Studio C# - Can someone explain to me why my code isn't working and how I can get it to work? 我正在尝试从 a.csv 读取信息并将其放入 C# 中的数组中。 谁能告诉我为什么代码不起作用? - I am trying to read information from a .csv and put it into an array in C#. Can anyone tell me why the code doesn't work? 有人可以正确地解释LINQ的交叉吗? 我不明白为什么这不起作用 - Can someone explain LINQ's intersect properly to me? I don't understand why this doesn't work 谁能告诉我为什么这不能解决 Project Euler 的问题 8? - Can anyone tell me why this doesn't work to solve Problem 8 of Project Euler? 有人可以帮我确定为什么 C# 工具提示不应该显示吗? - Can someone help me identify why C# tooltips show when they shouldn't? 有人可以向我解释为什么我的代码不起作用 - can someone explain to me why my code dosen't work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM