Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# winform重新绘制自身时出现问题_C#_Winforms_Timer_Paint - Fatal编程技术网

C# winform重新绘制自身时出现问题

C# winform重新绘制自身时出现问题,c#,winforms,timer,paint,C#,Winforms,Timer,Paint,我正在制作一个太空入侵者游戏。我有一个简单的算法,可以在入侵者被射杀时移除入侵者并添加分数 问题在于这一系列陈述: if (removeInvaderBool) { // removeInvader is an Invader object which was hit, and to be removed. Invaders.Score += removeInvader.addedScore; /

我正在制作一个太空入侵者游戏。我有一个简单的算法,可以在入侵者被射杀时移除入侵者并添加分数

问题在于这一系列陈述:

   if (removeInvaderBool)
            {
                  // removeInvader is an Invader object which was hit, and to be removed.
                Invaders.Score += removeInvader.addedScore;  //Invader class has got a property with a specific score (e.g. score 50). Score is a static field in the Invaders class.
                invaders.Remove(removeInvader);//invaders is a List<Invaders>
            }
调试你的程序。List.Remove()返回布尔值。利用这一点:

            Invaders.Score += removeInvader.addedScore;
            bool ok = invaders.Remove(removeInvader);
            System.Diagnostics.Debug.Assert(ok);

当入侵者不在列表中时,调试器将中断。考虑到您可能没有正确地实现它的均衡器()方法。

我们需要查看您的代码的其余部分,因为问题不在<代码>如果< /COD>语句。计时器是Syt.Wr.Obj.Ford.Type,对吗?是的,问题得到了解决。现在不是我照你说的做的时候。我认为问题不在那里。。我有一张30张的单子,在winform上只画了25张。其他的5个在哪里…(他们能一个接一个地画吗?!?是的,我发现了什么问题。我在同一个位置画了两个入侵者..这就是问题所在
            Invaders.Score += removeInvader.addedScore;
            bool ok = invaders.Remove(removeInvader);
            System.Diagnostics.Debug.Assert(ok);