I still suck at pointers and have no idea on how to fix this, so any help will be appreciated.
Maybe some help, this is how they do it in the tutorial section of the sfml tuts :
[cpp]
const sf::Input& Input = App.GetInput();
[/ccp]
[code]
1>c:\users\quincy\documents\visual studio 2008\projects\space snapper\space snapper\world.cpp(4) : error C2758: 'World::Input' : must be initialized in constructor base/member initializer list
1> c:\users\quincy\documents\visual studio 2008\projects\space snapper\space snapper\world.hpp(13) : see declaration of 'World::Input'
[/code]
[cpp]
//world.cpp
#include "world.hpp"
World::World()
{
GameWindow.Create(sf::VideoMode(800,600,32),"Space Snapper",sf::Style::Close,sf::WindowSettings(8,24,2));
GameWindow.SetFramerateLimit(100);
Input = GameWindow.GetInput();
std::cout<<"World Created !" << std::endl;
}
//world.hpp
#ifndef WORLD
#define WORLD
#include <iostream>
#include <vector>
#include <SFML/Graphics.hpp>
#include "BaseEnt.hpp"
#include "Cockpit.hpp"
class World
{
private:
sf::Input& Input;
sf::Event Event;
sf::RenderWindow GameWindow;
public:
std::vector<BaseEnt*> Entities;
World();
void Draw();
void Think();
void CreateCockpit();
sf::RenderWindow &GetApp() {return GameWindow;}
};
#endif
[/cpp]
This is only partial code.
Taking a stab here, References can never be null at any point, which means you probably need to assign it in a initialiser list like so:
[cpp]
World::World() :
GameWindow(sf::VideoMode(800,600,32),"Space Snapper", sf::Style::Close,sf::WindowSettings(8,24,2)), Input(GameWindow.GetInput())
{
GameWindow.SetFramerateLimit(100);
std::cout<<"World Created !" << std::endl;
}
[/cpp]
I don't understand :O, using brackets after declaring the gamewindow :O
Initializer lists. Look it up in for favorite reference.
Well it ain't working. So some more help ?
I also looked up initializers lists, but well I still well you know xD
[code]
1>------ Build started: Project: Space Snapper, Configuration: Debug Win32 ------
1>Compiling...
1>world.cpp
1>c:\users\quincy\documents\visual studio 2008\projects\space snapper\space snapper\world.cpp(3) : error C2470: 'World::{ctor}' : looks like a function definition, but there is no parameter list; skipping apparent body
1>c:\users\quincy\documents\visual studio 2008\projects\space snapper\space snapper\world.cpp(3) : error C2665: 'sf::VideoMode::VideoMode' : none of the 3 overloads could convert all the argument types
1> c:\users\quincy\documents\sfml\sfml-1.5\include\sfml\window\videomode.hpp(60): could be 'sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)'
1> while trying to match the argument list '(const char [4], const char [4], const char [3])'
1>c:\users\quincy\documents\visual studio 2008\projects\space snapper\space snapper\world.cpp(3) : error C2665: 'sf::WindowSettings::WindowSettings' : none of the 2 overloads could convert all the argument types
1> c:\users\quincy\documents\sfml\sfml-1.5\include\sfml\window\windowsettings.hpp(44): could be 'sf::WindowSettings::WindowSettings(unsigned int,unsigned int,unsigned int)'
1> while trying to match the argument list '(const char [2], const char [3], const char [2])'
1>c:\users\quincy\documents\visual studio 2008\projects\space snapper\space snapper\world.cpp(3) : error C2065: 'GameWindow' : undeclared identifier
1>c:\users\quincy\documents\visual studio 2008\projects\space snapper\space snapper\world.cpp(3) : error C2228: left of '.GetInput' must have class/struct/union
1> type is ''unknown-type''
[/code]
Edit :
Please :D
Sorry, you need to Log In to post a reply to this thread.