trigonometry - C++ Class Variable not updating -
i'm trying code counter class made in c++. i'm passing amount of time, deltat, method of wake class, adds onto value stored variable in class. code is:
void checkplayerwakes(int deltat){ for(size_t = 0; < game.getplayer().getwakes().size(); i++){ wake& w = game.getplayer().getwakes().at(i); w.age(deltat); } }
however, timer meant increasing, remaining @ 0. code change timer is:
void wake::age(int millis) { cout << "updating : " << currentlife; this->currentlife += millis; setalpha(((double)currentlife)/((double)lifetime)); cout << " " << currentlife << endl; } e.g. first current life: 0 second current life: 16
i know if use
wake w = w.age(deltat)
it wouldn't work because "w" copy of object. however, that's not problem here? game.getplayer() returns reference, playership&.
last time had similar problem, solved calling , returning references instead of classname. still doing wrong?
getwakes()
needs return reference, , should return vector&
opposed vector. i'm adding here make sure question marked answered.
Comments
Post a Comment