Omnimaga

General Discussion => Technology and Development => Computer Programming => Topic started by: Scipi on July 22, 2011, 01:46:20 pm

Title: Object not created properly inside a class
Post by: Scipi on July 22, 2011, 01:46:20 pm
I'm getting an error with some of my C++ code for Daemons (It's the last in a long list of errors preventing screenshots) and I have no idea how to fix it.

The error is: Game.Game::App does not have class type.

Here's the code for the creation of App
Code: [Select]
class Game
{
public:

        sf::RenderWindow App();
        vector <sf::Sprite> SpriteFiles;

        void Setup();
        void MainMenu();
        void GetEvents();

        void LevelUp(string, int*);//Daemon name, pointer to Daemon stats array

Game();
~Game();
private:
bool FilesExist;
stringstream PictureName;
char ImageNum;
vector <sf::Image> ImageFiles;
};

And here's one example of it's usage

Code: [Select]
void Map::Display()
{
Game.App.Clear();

for (int y=PosY; y<ScreenHeight; y++)
{
for (int x=PosX; x<ScreenWidth; x++)
{
if (y >= 0 && x >= 0)
{
if (MapData[x + (y * MapWidth)] == -1)
continue;

Game.SpriteFiles[MapData[x + (y * MapWidth)]].SetPosition(x * 64, y * 64);

Game.App.Draw(Game.SpriteFiles[MapData[x + (y * MapWidth)]]);
}
}

}
Game.App.Display();
return;
}

Any ideas on how to get App to work? It has a class type (An sf::RenderWindow) which is a drawable window. :(
Title: Re: Object not created properly inside a class
Post by: Munchor on July 24, 2011, 09:40:39 am
How many files are there? Could you upload all of them and tell us how to compile please? That would make it easier for us to help you :)
Title: Re: Object not created properly inside a class
Post by: Scipi on July 25, 2011, 06:51:59 pm
I found out what was going wrong. I had to remove the () from sf::RenderWindow App();