|
|
error: no matching function for call to sf::RenderWindow::pollEvent(sf::Event*) candidate is: bool sf::Window::pollEvent(sf::Event&) can't convert ‘sf::Event*’ to ‘sf::Event&’ |
|
|
|
|
& can be read as "address of" * can be read as "value pointed by" |
p_gamesys->getGameEvents
ok, but if pointers and references are not the same thing, how can i create a function which is of the pointer type (sf::Event* GameSys::getGameEvents()) and it successfully return an address (return &game_events;)? |
oh, i'm sticking to the manual from this site, which says:
|
geez, is there any idea to make this code a bit cleaner? i just want to have access to the original sf::Event object. |
For one thing you could stop naming a single event object as if it were more than one event (and do the same of the getter function.) Not exposing the event to the rest of the code in this manner would also be nice. Consider using callbacks |
-what do you mean by "baming a single event as if it were more than one"? are you just saying that the variable name should be simplified? |
-the event is exposed just where it needs to be. better than that, the only way i see is creating a copy of it everytime the loop runs... |
|
|
-and how do i use callbacks in this case? can someone show a little piece of code? |
|
|
And it is definitely not exposed just where it needs to be. For instance, in main, one may call gamesys.getGameEvents, obtain a pointer to the event object and modify the event object at any time one wishes. There is no reason for that to be possible. |
|
|
|
|
i understand what you say. that is because the code isn't complete, it's simplified. but i need the game_event object outside the runGame() function also. |
the compiler does not complain about the getGameWindow() function, but does complain about the getGameEvents(). why would that happen?? |
pollEvent(*(p_gamesys->getGameEvents()))