Dipankar Upadhyay
Dipankar Upadhyay

Reputation: 11

Error While using schedule_selector in Cococs2d-x

When i am using this

   void addCats();//Declareation in .h file
   this->schedule( schedule_selector(HelloWorld::addCats()), 2.0 );//addCats is a function

It Working Fine addCats function call every time, But When i am using

 //In.h file
 void addCats(int);
 //In.cpp file
 int i=10;
 this->schedule( schedule_selector(HelloWorld::addCats(i)), 2.0 );

Then it give error :: lvalue is required as unary '&' operand. Please Clearify it, what is the issue, how it work....

And please refer any link or PDF for Cocos2d-X tutorial & study...

Thank you vey much....

Upvotes: 1

Views: 1412

Answers (1)

Nikhil Aneja
Nikhil Aneja

Reputation: 1259

Hi I also tried this and ran into the problem.. After a bit of googling and looking into structure I found why this is working like this.. When you go deep in its structure.. It converts it as

addCats(CCTime time)

You can not assign a variable in C++ like this instead it is actually a comparison with your time 2.0 given.

So try your method like this

//In.h file
 void addCats(cocos2d::ccTime time);
 //In.cpp file

this->schedule( schedule_selector(HelloWorld::addCats), 2.0 );
addCats(CCTime time)
{

}

Use a break point in your method. You will come to know that your time value is 2.0 . This lvalue problem arises when you assign when you need to compare. Hope this helps. :)

Upvotes: 2

Related Questions