alayer
#include "ALayer.hpp"
ALayer::ALayer(void)
{
}
ALayer::~ALayer(void)
{
}
bool ALayer::init()
{
bool bRet=false;
do
{
CC_BREAK_IF(!CCLayer::init());
bRet=true;
} while (0);
return bRet;
}
void ALayer::Post()
{
CCLOG("pos");
CCString* str=CCString::create("Hello BLayer!");
CCNotificationCenter::sharedNotificationCenter()->postNotification("BMessage",str);
}
blayer
#include "BLayer.hpp"
BLayer::BLayer(void)
{
}
BLayer::~BLayer(void)
{
CCNotificationCenter::sharedNotificationCenter()->purgeNotificationCenter();
}
bool BLayer::init()
{
bool bRet=false;
do
{
CC_BREAK_IF(!CCLayer::init());
CCNotificationCenter::sharedNotificationCenter()->addObserver(this,callfuncO_selector(BLayer::getMessage),"BMessage",NULL);
bRet=true;
} while (0);
return bRet;
}
void BLayer::getMessage(CCObject* obj)
{
CCString* str=static_cast<CCString*>(obj);
CCLog(str->getCString());
}
testlayer
_aLayer=ALayer::create();
this->addChild(_aLayer);
_bLayer=BLayer::create();
this->addChild(_bLayer);
_aLayer->Post();