//
// Created by sky on 14-8-19.
#include <iostream>
#include "cocos2d.h"
#include "cocos-ext.h"
USING_NS_CC;
USING_NS_CC_EXT;
class DaojuHelpLayer:public CCLayer,
public CCNodeLoaderListener,
public CCBSelectorResolver,
public CCBMemberVariableAssigner
{
private:
CCScrollView *m_pScrollView;
CCControlButton *m_pButton;
void onBackBtnCallback(CCObject *p,CCControlEvent *e);
public:
static CCScene* createScene();
static CCNode* createDaojuHelpLayer();
DaojuHelpLayer();
~DaojuHelpLayer();
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(DaojuHelpLayer, create);
//节点加载完毕调用
virtual void onNodeLoaded(CCNode * pNode, CCNodeLoader * pNodeLoader);
//实现CCBMemberVariableAssigner接口, 连接变量
virtual bool onAssignCCBMemberVariable(CCObject* pTarget, const char* pMemberVariableName, CCNode* pNode);
//实现CCBSelectorResolver接口, 用于连接菜单项
virtual SEL_MenuHandler onResolveCCBCCMenuItemSelector(CCObject * pTarget, const char* pSelectorName);
//实现CCBSelectorResolver接口, 用于连接CCControl
virtual SEL_CCControlHandler onResolveCCBCCControlSelector(CCObject * pTarget, const char* pSelectorName);
};
class CCBReader;
class DaojuHelpLayerLoader:public CCLayerLoader
{
public:
//使用loader创建loader类
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(DaojuHelpLayerLoader, loader);
protected:
//调用create方法创建DaojuHelpLayer类对象
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(DaojuHelpLayer);
};
// Created by sky on 14-8-19.
#include <iostream>
#include "cocos2d.h"
#include "cocos-ext.h"
USING_NS_CC;
USING_NS_CC_EXT;
class DaojuHelpLayer:public CCLayer,
public CCNodeLoaderListener,
public CCBSelectorResolver,
public CCBMemberVariableAssigner
{
private:
CCScrollView *m_pScrollView;
CCControlButton *m_pButton;
void onBackBtnCallback(CCObject *p,CCControlEvent *e);
public:
static CCScene* createScene();
static CCNode* createDaojuHelpLayer();
DaojuHelpLayer();
~DaojuHelpLayer();
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(DaojuHelpLayer, create);
//节点加载完毕调用
virtual void onNodeLoaded(CCNode * pNode, CCNodeLoader * pNodeLoader);
//实现CCBMemberVariableAssigner接口, 连接变量
virtual bool onAssignCCBMemberVariable(CCObject* pTarget, const char* pMemberVariableName, CCNode* pNode);
//实现CCBSelectorResolver接口, 用于连接菜单项
virtual SEL_MenuHandler onResolveCCBCCMenuItemSelector(CCObject * pTarget, const char* pSelectorName);
//实现CCBSelectorResolver接口, 用于连接CCControl
virtual SEL_CCControlHandler onResolveCCBCCControlSelector(CCObject * pTarget, const char* pSelectorName);
};
class CCBReader;
class DaojuHelpLayerLoader:public CCLayerLoader
{
public:
//使用loader创建loader类
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(DaojuHelpLayerLoader, loader);
protected:
//调用create方法创建DaojuHelpLayer类对象
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(DaojuHelpLayer);
};
//
// DaojuHelpLayer.cpp
//
// Created by sky on 14-8-19.
//
//
#include "DaojuHelpLayer.h"
DaojuHelpLayer::DaojuHelpLayer()
{
}
DaojuHelpLayer::~DaojuHelpLayer()
{
}
CCScene* DaojuHelpLayer::createScene()
{
CCScene *scene = CCScene::create();
CCNodeLoaderLibrary *ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
ccNodeLoaderLibrary -> registerCCNodeLoader("DaojuHelpLayer", DaojuHelpLayerLoader::loader());
cocos2d::extension::CCBReader *reader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
reader -> autorelease();
CCNode *node = reader->readNodeGraphFromFile("DaojuHelpUI", scene);
CCAssert(node!=NULL, "读取失败");
scene -> addChild(node);
return scene;
}
CCNode* DaojuHelpLayer::createDaojuHelpLayer()
{
CCNodeLoaderLibrary *ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
ccNodeLoaderLibrary -> registerCCNodeLoader("DaojuHelpLayer", DaojuHelpLayerLoader::loader());
cocos2d::extension::CCBReader *reader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
reader -> autorelease();
CCNode *node = reader->readNodeGraphFromFile("DaojuHelpUI");
CCAssert(node!=NULL, "读取失败");
return node;
}
void DaojuHelpLayer::onNodeLoaded(cocos2d::CCNode *pNode, cocos2d::extension::CCNodeLoader *pNodeLoader)
{
CCLog("you will enter the daoju help layer...");
CCLog("tag:%d",m_pScrollView->getTag());
CCLog("maxoffset:%f,%f",m_pScrollView->minContainerOffset().x,m_pScrollView->minContainerOffset().y);
m_pScrollView -> setContentOffset(m_pScrollView->minContainerOffset());
}
bool DaojuHelpLayer::onAssignCCBMemberVariable(cocos2d::CCObject *pTarget, const char *pMemberVariableName, cocos2d::CCNode *pNode)
{
// CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mScrollView", CCScrollView*, this->m_pScrollView);
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "backBtn", CCControlButton*, this->m_pButton);
CCB_MEMBERVARIABLEASSIGNER_GLUE_WEAK(this, "mScrollView", CCScrollView*, this->m_pScrollView);
return false;
}
SEL_MenuHandler DaojuHelpLayer::onResolveCCBCCMenuItemSelector(cocos2d::CCObject *pTarget, const char *pSelectorName)
{
return NULL;
}
SEL_CCControlHandler DaojuHelpLayer::onResolveCCBCCControlSelector(cocos2d::CCObject *pTarget, const char *pSelectorName)
{
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "backToMain", DaojuHelpLayer::onBackBtnCallback);
return NULL;
}
void DaojuHelpLayer::onBackBtnCallback(cocos2d::CCObject *p, CCControlEvent *e)
{
CCLog("backBtn callback...");
}
// DaojuHelpLayer.cpp
//
// Created by sky on 14-8-19.
//
//
#include "DaojuHelpLayer.h"
DaojuHelpLayer::DaojuHelpLayer()
{
}
DaojuHelpLayer::~DaojuHelpLayer()
{
}
CCScene* DaojuHelpLayer::createScene()
{
CCScene *scene = CCScene::create();
CCNodeLoaderLibrary *ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
ccNodeLoaderLibrary -> registerCCNodeLoader("DaojuHelpLayer", DaojuHelpLayerLoader::loader());
cocos2d::extension::CCBReader *reader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
reader -> autorelease();
CCNode *node = reader->readNodeGraphFromFile("DaojuHelpUI", scene);
CCAssert(node!=NULL, "读取失败");
scene -> addChild(node);
return scene;
}
CCNode* DaojuHelpLayer::createDaojuHelpLayer()
{
CCNodeLoaderLibrary *ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
ccNodeLoaderLibrary -> registerCCNodeLoader("DaojuHelpLayer", DaojuHelpLayerLoader::loader());
cocos2d::extension::CCBReader *reader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
reader -> autorelease();
CCNode *node = reader->readNodeGraphFromFile("DaojuHelpUI");
CCAssert(node!=NULL, "读取失败");
return node;
}
void DaojuHelpLayer::onNodeLoaded(cocos2d::CCNode *pNode, cocos2d::extension::CCNodeLoader *pNodeLoader)
{
CCLog("you will enter the daoju help layer...");
CCLog("tag:%d",m_pScrollView->getTag());
CCLog("maxoffset:%f,%f",m_pScrollView->minContainerOffset().x,m_pScrollView->minContainerOffset().y);
m_pScrollView -> setContentOffset(m_pScrollView->minContainerOffset());
}
bool DaojuHelpLayer::onAssignCCBMemberVariable(cocos2d::CCObject *pTarget, const char *pMemberVariableName, cocos2d::CCNode *pNode)
{
// CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mScrollView", CCScrollView*, this->m_pScrollView);
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "backBtn", CCControlButton*, this->m_pButton);
CCB_MEMBERVARIABLEASSIGNER_GLUE_WEAK(this, "mScrollView", CCScrollView*, this->m_pScrollView);
return false;
}
SEL_MenuHandler DaojuHelpLayer::onResolveCCBCCMenuItemSelector(cocos2d::CCObject *pTarget, const char *pSelectorName)
{
return NULL;
}
SEL_CCControlHandler DaojuHelpLayer::onResolveCCBCCControlSelector(cocos2d::CCObject *pTarget, const char *pSelectorName)
{
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "backToMain", DaojuHelpLayer::onBackBtnCallback);
return NULL;
}
void DaojuHelpLayer::onBackBtnCallback(cocos2d::CCObject *p, CCControlEvent *e)
{
CCLog("backBtn callback...");
}