In my game I have an animated sprite. I added box2d to my game to add gravity. now I want to update my sprite’s position using the schedule function. I got it working with objective-C, but I want it to be a multiplatform game so now I’m trying it in c++.
I get the following error on the line in my init: "cannot cast from type ‘void’ to member pointer type ‘coco2d::sel_schedule’ (aka void coco2d::CCobject::*)(float)
I have no idea what to do now. I tried to google, but everyone either uses objective - c or schedule_selector (which apparently doesn’t work anymore)
Hi!
When you write View::tick(1.0f) the compiler think that it is call of tick method with parameter 1.0f, and the tick returns void - so it’s difficult to cast void to method pointer.
You should use schedule like this:
schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay)
Thanks very much. I don’t have access to a mac atm, but I’ll try this tomorrow.
A question though: My tick method needs a float parameter. If I use this->schedule(cocos2d::SEL_SCHEDULE(&View::tick), 1.0f, kCCRepeatForever, 0); , what value will the parameter be? Will it take the value of the interval parameter and be 1.0f?