Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Fsmv

Pages: [1]
1
Window / Pointer to the Input class
« on: May 22, 2010, 02:22:32 am »
Thanks problem solved.

2
Window / Pointer to the Input class
« on: May 21, 2010, 01:49:47 am »
I have a separate class that needs to access the input data from the main loop. I was trying to use a pointer like I did for the render window but Input won't let me. Sorry I don't know much about pointers. Is reason that the constant is already a pointer and I need to convert it somehow?

My code is:

Code: [Select]
const sf::Input& Input = renderWindow.GetInput();
//*********************************************************
sf::Input &input = Input;   //This same approach worked for
menu.setInput(&input);   //pointing to the renderWindow
//**********************************************************

while(renderWindow.IsOpened()) {
        // Process events
        sf::Event Event;
        while (renderWindow.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                renderWindow.Close();
}

// Fill the background black
renderWindow.Clear(sf::Color(0, 0, 0, 255));

//if menu is not done run the menu loop otherwise start the rest of the program
if(!menu.cleanMenu()){
bool bResult = lgcManager.Loop();
}else{
menu.loop();
}

        // Display window contents on screen
        renderWindow.Display();
}

Where I try to get it I have:
Code: [Select]
void MainMenu::setInput(sf::Input inp){
mpInput = inp;
}


The error I get is:
Code: [Select]
error C2440: 'initializing' : cannot convert from 'const sf::Input' to 'sf::Input &'
1>        Conversion loses qualifiers


I need to know how to point to the input constant so I can get input in other classes.

Pages: [1]