Hi,
I'm familiar with OOP with Java or Actionscript, but now I must finish an application written in C++, and there's an error that seems to not get away, and it's been hard to figure out why.
I have two classes, one called TestNetwork, and the other called MyNetwork.
MyNetwork at a given time, must trigger an animation, but when that animation ends I want to change the variable "action" wich is in the TestNetwork.
Well I included the "testNetwork.h" in MyNetwork, and made a method in TestNetwork that supposedly should change that variable. I'll try to paste the only needed code for this, wich is giving me the error.
myNetwork.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
...
#include "testNetwork.h
...
void MyNetwork::Update(const double deltaFrameTime)
{
//Animate greeting
while (!greetList.empty())
{
std::string id = greetList.front();
StringObjectMap::iterator iter = mOtherPlayerMap.find(id);
if (iter != mOtherPlayerMap.end())
{
if(!(*iter).second->IsAnimationPlaying("Wave"))
{
(*iter).second->ClearAllAnimations(0.25f);
(*iter).second->PlayAnimation("Wave");
(*iter).second->Update(deltaFrameTime);
}else{
(*iter).second->Update(deltaFrameTime);
}
TestNetwork::setAction(1);
}
greetList.pop_front();
}
}
|
testNetwork.h (These declarations are on the public section)
1 2
|
static void setAction(int value);
int action;
|
testNetwork.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
void TestNetwork::setAction(int value)
{
action=value; //C2597 Error here <--
}
void TestNetwork::UpdateWave()
{
dtCore::Timer timer;
dtCore::Timer myTimer;
dtCore::Timer_t prevTime=myTimer.Tick();
dtCore::Timer_t curTime;
float timeElapsed;
bool passou=true;
do{
curTime=myTimer.Tick();
timeElapsed=myTimer.DeltaSec(prevTime, curTime);
if(timeElapsed >= 4.5){
action=1;
pass=false;
mNet->greetList.pop_front();
}
}while(pass==true);
}
|
In this last section, I'm confuse (hope some enlightment), because inside setAction I try to change the value of the variable action and it produces the error, and inside updateWave, the same variable is changed with no problem.
The Error:
|
Error 1 error C2597: illegal reference to non-static member 'TestNetwork::action' f:\IMVU\VisualC - Colisions - Big Room and Avatars & Sound & Animation Loops\testNetwork.cpp 416
|
Probably this is an easy one for you, but I'm not getting it. If you need more info, be free to ask.
Thanks.
Leonel