c++ - Schedule selector error -
i'm trying port iphone app windows 8, have problem line (it's objective-c) :
[self schedule:@selector(fire:)];
the equivalent on c++ should :
this->schedule(schedule_selector(airscene::fire));
where airscene name of class, have error returning visual studio 2012 :
error c2064: term not evaluate function taking 1 arguments
so, in other words function schedule(selector) not found. it's strange because have no problem unschedule method, have idea please ?
edit : airscene.h
#include "cocos2d.h" #include "box2d\box2d.h" #include "airscenedelegate.h" class airscene : public cocos2d::cclayer { public: airscene::~airscene(void); // here's difference. method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone virtual bool init(); static cocos2d::ccscene* scene(); layer_node_func(airscene); //methods void selectspritefortouch(cocos2d::ccpoint touchlocation); cocos2d::ccpoint checkpuckposition(cocos2d::ccpoint newposition); void panfortranslation(cocos2d::ccpoint translation); void updatequestion(string question); void restorescene(); void enablescreensaver(); void disablescreensaver(cocos2d::ccpoint touchposition); //setters void setdelegate(airscenedelegate *delegate); private: // init void initbackground(cocos2d::ccsize winsize); void initpuck(cocos2d::ccsize winsize, cocos2d::ccpoint position); void initholes(cocos2d::ccsize winsize); void initquestion(cocos2d::ccsize winsize); // methods void fire(cocos2d::cctime dt = 0); void updateholes(cocos2d::cctime dt); void validatevote(bool ispositivevote); float getvelocity(); // attributes ... //delegate airscenedelegate* _delegate; };
airscene.cpp
#include <iostream> #include "airscene.h" using_ns_cc; #pragma region delete airscene::~airscene(void) { ///todo : delete delete(_delegate); _delegate = 0; } #pragma endregion delete #pragma region init ccscene* airscene::scene() { // 'scene' autorelease object ccscene *scene = ccscene::node(); // 'layer' autorelease object airscene *layer = airscene::node(); // add layer child scene scene->addchild(layer); // return scene return scene; } // on "init" need initialize instance bool airscene::init() { // super init if (!cclayer::init()) return false; //init attributes screensavermode = false; hasvoted = false; schedule = false; _delegate = 0; _selsprite = null; //create world b2vec2 gravity = b2vec2(0, 0); _world = new b2world(gravity); ccsize size = ccdirector::shareddirector()->getwinsize(); //inits airscene::initbackground(size); airscene::initpuck(size, ccp(512, 200)); airscene::initholes(size); airscene::initquestion(size); return true; } // init background , set walls void airscene::initbackground(ccsize winsize) { ... } /** init puck : create puck body , shape */ void airscene::initpuck(ccsize winsize, ccpoint position) { ... } void airscene::initholes(ccsize winsize) { ... } // set question label void airscene::initquestion(ccsize winsize) { ... } #pragma endregion init #pragma region private void airscene::fire(cctime dt) { _world->step(dt, 8, 8); //ccsprite *balldata = ((ccsprite *)_body->getuserdata()) ((ccsprite *)_body->getuserdata())->setposition(ccp(_body->getposition().x * ptm_ratio, _body->getposition().y * ptm_ratio)); _puckshadow->setposition(ccp(((ccsprite *)_body->getuserdata())->getposition().x + 2, ((ccsprite *)_body->getuserdata())->getposition().y - 2)); if (screensavermode) airscene::updateholes(0); } //ajust glow effect , validate vote void airscene::updateholes(cocos2d::cctime dt) { ... } float airscene::getvelocity() { ... } void airscene::validatevote(bool ispositivevote) { ... } #pragma endregion private #pragma region public void airscene::selectspritefortouch(ccpoint touchlocation) { ... } // check if puck not outside view ccpoint airscene::checkpuckposition(ccpoint newposition) { ... } // move puck void airscene::panfortranslation(ccpoint translation) { ... } // update question void airscene::updatequestion(string question) { ... } void airscene::restorescene() { ... } void airscene::enablescreensaver() { screensavermode = true; ccsize winsize = ccdirector::shareddirector()->getwinsize(); //unschedule actions this->unscheduleallselectors(); //delete puck ccpoint puckposition = _puck->getposition(); _puck->removeallchildrenwithcleanup(true); _puck->removefromparentandcleanup(true); _puckshadow->removeallchildrenwithcleanup(true); _puckshadow->removefromparentandcleanup(true); _world->destroybody(_body); delete(_puck); delete(_puckshadow); //recreatepuck this->initpuck(winsize, ccp(512, 200)); //impulse _body->setlinearvelocity(b2vec2(0, 0)); /** error caused line */ this->schedule(schedule_selector(airscene::fire)); } void airscene::disablescreensaver(cocos2d::ccpoint touchposition) { } #pragma endregion public #pragma region getters & setters void airscene::setdelegate(airscenedelegate *delegate) { _delegate = delegate; } #pragma endregion getters & setters
fixed.
the version of cocos 2d used windows 8 template old version, way schedule selector 1 :
ccscheduler::sharedscheduler()->scheduleselector(schedule_selector(airscene::fire), this, 0, false);
Comments
Post a Comment