简体   繁体   中英

No overload for Method takes 0 arguments

I'm currently working on a game in XNA for my school project. 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 . 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.

The problem occours in my BallUpdate method where I call for CheckCollisionWall Method

public void Update()
{
     position += motion * ballSpeed;
     CheckCollisionWall();
     OffBottom();
}

It says no Overload for that method takes 0 arguments. 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

  1. Find out which call causes this compiler error. (In your case it is the call CheckCollisionWall();
  2. Have a close look at the number and types of arguments in this call. (In your case it is zero arguments)
  3. Find all definitions of this method. (You may use Find or Find Usages or intellisense in Visual studio)
  4. Compare all definitions/overloads with your call.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM