Reputation: 111
Here is a code snippet:
public Menu(ContentManager Content)
{
gameLogic = new GameLogic(Content);
LoadContent(Content);
}
That is the constructor for my Menu class in a tiny game I'm doing for a school project. I need to reach the GameLogic, so that I can call it to draw and update from Menu, in case my enum gamestate changes from Menu to Game.
However, Visual Studio has a problem with this, giving me the error that "Cannot assing to gameLogic because it is a Method group". It's not wrong, GameLogic is a class, and a class is a group of methods.
My question is simply, how can I reach GameLogic and call on it's methods in the Menu class without having this problem? Any help would be appreciated!
EDIT:
Upon request I'll be adding more code, here's a more detailed code snippet:
class Menu
{
GameLogic gameLogic();
public enum GameState { Menu, Game, HighScore };
public GameState gameState = GameState.Menu;
public Menu(ContentManager Content)
{
gameLogic = new GameLogic(Content);
LoadContent(Content);
}
The line which recieves the error is "gameLogic = new GameLogic(Content);" I added the enum part to show why I need to reach gamelogic, so that I can update the gamelogic or draw it when enum is Game (I'm going to do the same with my HighScoreclass as well, that will show a high score list, so it's good if I get a solution ^^)
Upvotes: 1
Views: 8835
Reputation: 73482
GameLogic gameLogic();
Variables don't take ()
. When you add parenthesis language consider them as "Methods".
Change it to the following should get rid of the error
GameLogic gameLogic;
Upvotes: 1