cocos2d 消息映射

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();
上一篇:Android activity_main.xml删除边缘距离,充满屏幕


下一篇:NGINX(六)扩展