私はcocos2d-xが初めてです。この行でエラーが発生しています:
Button* btnRegister=static_cast<Button*>(Helper::seekWidgetByName(m_pLayout, "btnRegister"));
btnRegister->addTouchEventListener(CC_CALLBACK_0(LoginScene::GameLoginTest, this));//get error no matching member function for call to addtoucheventlistener
以下のコンストラクターを既に作成しているため、理由がわかりません。助けてください。それを修正するにはどうすればよいですか
ファイル LoginScene.h
#include "cocos2d.h"
#include "cocos-ext.h"
#include "CocosGUI.h"
USING_NS_CC;
USING_NS_CC_EXT;
using namespace ui;
class LoginScene : public Scene
{
public:
LoginScene(bool pPortrait=false);
~LoginScene();
// there's no 'id' in cpp, so we recommend returning the class instance pointer
//static cocos2d::Scene* createScene();
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
//virtual bool init();
virtual void onEnter();
virtual void onExit();
// a selector callback
virtual void GameLogin();
void GameLoginTest(Ref* pSender,TouchEventType type);
//virtual void runThisTest()=0;
protected:
Layer* m_pUILayer;
Layout* m_pLayout;
int authenticate();
//int authenticate(const char* username, const char* password);
// implement the "static create()" method manually
//CREATE_FUNC(LoginScene);
};
ファイル LoginScene.cpp
#include "LoginScene.h"
#include "cocostudio/CCSSceneReader.h"
#include "cocostudio/CCSGUIReader.h"
#include "cocostudio/CCActionManagerEx.h"
#include "LoadingScene.h"
#include "MainScene.h"
#include "curl/curl.h"
LoginScene::LoginScene(bool pPortrait):m_pUILayer(NULL),m_pLayout(NULL)
{
Scene::init();
}
LoginScene::~LoginScene()
{
}
void LoginScene::onEnter()
{
Scene::onEnter();
m_pUILayer=Layer::create();
m_pUILayer->scheduleUpdate();
this->addChild(m_pUILayer);
m_pLayout=dynamic_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("LoginScene.json"));
m_pUILayer->addChild(m_pLayout);
Button* btnLogin = static_cast<Button*>(Helper::seekWidgetByName(m_pLayout, "btnLogin"));
btnLogin->addTouchEventListener(CC_CALLBACK_0(LoginScene::GameLogin, this));//it's okay
Button* btnRegister=static_cast<Button*>(Helper::seekWidgetByName(m_pLayout, "btnRegister"));
btnRegister->addTouchEventListener(CC_CALLBACK_0(LoginScene::GameLoginTest, this));
//get error no matching member function for call to addtoucheventlistener
}
void LoginScene::GameLogin()
{
auto scene=LoadingScene::createScene();
Director::getInstance()->pushScene(scene);
}
void LoginScene::GameLoginTest(Ref* pSender,TouchEventType type)
{
if (type==TOUCH_EVENT_ENDED)
{
if (authenticate()==1)
{
auto scene=MainScene::createScene();
Director::getInstance()->pushScene(TransitionFade::create(2.3f, scene));
}
}
}