[英]No overload for Method takes 0 arguments
I'm currently working on a game in XNA for my school project. 我目前正在为学校项目开发XNA游戏。 Its including paddle and a ball and the idea is to force the ball to leave top border and then you proceed to next harder level and you go until you die. 它包括桨和一个球,其想法是迫使球离开顶部边界,然后您进入下一个更困难的水平,直到死亡。 So this is how my victory-detecting piece of code looks like: 因此,这就是我检测胜利的代码的样子:
if (position.Y < 0 && pbcollide == true)
{
MessageBox(new IntPtr(0), "Level cleared!", "Nice job", 0);
paddle.SetInStartPosition();
paddle.lvcounter++;
}
That piece of code is in my CheckCollisionWall
method in my Ball
class and pbcollide
is bool
var I get from Method CheckCollisionPaddle
. CheckCollisionWall
代码在Ball
类的CheckCollisionWall
方法中,而pbcollide
是从方法CheckCollisionPaddle
获取的bool
CheckCollisionPaddle
。 I have divided classes for Ball
and Paddle
, and SetInStartPosition
is Paddle
class method and lvcounter
is Paddle
class variable that I use to count levels and increase ball and decrease paddle speed, spawn more powerups etc. 我为Ball
和Paddle
划分了类, SetInStartPosition
是Paddle
类的方法, lvcounter
是Paddle
类的变量,我用它来计算级别并增加球和降低桨的速度,产生更多的功率提升等。
The problem occours in my BallUpdate
method where I call for CheckCollisionWall
Method 问题出现在我的BallUpdate
方法中,我在其中调用CheckCollisionWall
方法
public void Update()
{
position += motion * ballSpeed;
CheckCollisionWall();
OffBottom();
}
It says no Overload for that method takes 0 arguments. 它说该方法的重载都不接受0个参数。 Which arguments should I put there? 我应该把哪些论点放在那儿? I really don't know what to do. 我真的不知道该怎么办。 I also tried to put my win condition in totaly new method to avoid this but when I do that game starts without errors but absolutely nothing happens when conditions are fulfilled. 我还尝试将获胜条件置于全新的方法中以避免发生这种情况,但是当我这样做时,游戏开始时没有错误,但条件满足时绝对没有任何反应。 So I'm totally confused. 所以我完全糊涂了。
How to solve 怎么解决
No overload for Method takes X arguments 方法不带X参数的重载
CheckCollisionWall();
(您的情况是调用CheckCollisionWall();
Find
or Find Usages
or intellisense in Visual studio) (您可以在Visual Studio中使用“ Find
或“ Find Usages
或“智能”) The error is caused, when you use a call with a different number of arguments or when at least one argument has a different type when compared to the available definitions/overloads. 当您使用带有不同数量参数的调用时,或者与可用定义/重载相比,至少一个参数具有不同类型时,会导致错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.