having problems with Time-Sfml

I'm trying sfml but I just can't seem to get the hang of TIME, for some reason this
function here doesn't work as I would expect it to?

1
2
3
4
5
6
7
8
9
10

#include <sfml/graphics.hpp>
using namespace std;
		Time aclock(Clock test4,Time timefr,Time timefr2){
    if( timefr.asSeconds() > timefr2.asSeconds() ){
            cout<<"activates!";
cout<<timefr.asSeconds();}
else{
    timefr = test4.getElapsedTime();
    cout<<timefr2.asSeconds()<<" limit? \n";}}

I would expect it to be a timer, but for some reason, it just prints out the limit? even when the timefr is greater than the timefr2? why is that?, also, it seems to work when it isn't a function(if I just paste the code into the main it works as expected)
Last edited on
it just prints out the limit? even when the timefr is greater than the timefr2?

Clearly that can't be the case. Why don't you print out the values of timefr.asSeconds() and timefr2.asSeconds() BEFORE the if statement ... just to make sure that your parameters have the values that you think they have.



also, it seems to work when it isn't a function(if I just paste the code into the main it works as expected)
Which suggests that you are calling it incorrectly ... but we can't tell, because you haven't posted enough code.



BTW - your function doesn't return anything, despite its prototype declaring that it should return something of type Time. Also, your indentation is doing more harm than good here.
Last edited on
Topic archived. No new replies allowed.