inline void raise( const char* file_name, const char* function_name, int line_number, const char* cond, const char* fmt, ... ) { va_list args; va_start( args, fmt ); if (handler_function != nullptr) { handler_function(file_name,function_name,line_number,cond,fmt,args); } va_end( args ); }
void LevelScene::inialize() { GameModel* gameModel = GameModel::getInstance(); this->gameEventListener = new GameEventListener(); this->gameEventListener->setHandlerObject(this); this->gameEventListener->setHandlerFunction(handler_function(LevelScene::processEvent)); gameModel->addEventListener(this->gameEventListener); this->touchListener = EventListenerTouchOneByOne::create(); this->touchListener->onTouchBegan = CC_CALLBACK_2(LevelScene::onTouchBegan, this); this->touchListener->onTouchMoved = CC_CALLBACK_2(LevelScene::onTouchMoved, this); this->touchListener->onTouchEnded = CC_CALLBACK_2(LevelScene::onTouchEnded, this); this->touchListener->onTouchCancelled = CC_CALLBACK_2(LevelScene::onTouchEnded, this); this->_eventDispatcher->addEventListenerWithSceneGraphPriority(this->touchListener, this); this->keyBoardListener = EventListenerKeyboard::create(); this->keyBoardListener->onKeyPressed = CC_CALLBACK_2(LevelScene::onKeyPress, this); this->keyBoardListener->onKeyReleased = CC_CALLBACK_2(LevelScene::onKeyRelease, this); this->_eventDispatcher->addEventListenerWithSceneGraphPriority(this->keyBoardListener, this); this->createLayers(); this->createLayersContent(); }
virtual int operator()() override { return handler_function(); }
void Controller::listen(View *view){ auto listener = new GameEventListener(); listener->setHandlerObject(this); listener->setHandlerFunction(handler_function(Controller::processEvent)); view->addEventListener(listener); }