123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- //
- // BulldogMapIconAdLayer.cpp
- // BubbleShoot
- //
- // Created by 刘玉涛 on 17/9/1.
- //
- //
- #include "RUBulldogMapIconAdLayer.h"
- #include "BulldogIconAdController.h"
- #include "RedAdLayerController.h"
- #include "BulldogIconLayer.h"
- NS_RU_BEGIN
- BulldogMapIconAdLayer * BulldogMapIconAdLayer::Layer(){
- redream::NodeLoaderLibrary *lib = redream::NodeLoaderLibrary::newDefaultNodeLoaderLibrary();
- lib->registerNodeLoader("BulldogMapIconAdLayer", BulldogMapIconAdLayerLoader::loader());
- redream::REDReader *reader = new(std::nothrow) redream::REDReader(lib);
- reader->autorelease();
- BulldogMapIconAdLayer * node = (BulldogMapIconAdLayer*)reader->readNodeGraphFromFile("BulldogMapIconAdLayer.redream");
-
- return node;
- }
- bool BulldogMapIconAdLayer::onAssignREDMemberVariable(Ref* pTarget, const char* pMemberVariableName, Node* pNode){
- // RED_MEMBERVARIABLEASSIGNER_GLUE_WEAK(this, "btnClose", ControlButton*, BulldogMapIconAdLayer::btnClose);
- RED_MEMBERVARIABLEASSIGNER_GLUE_WEAK(this, "btnOpen", ControlButton*, BulldogMapIconAdLayer::btnOpen);
- RED_MEMBERVARIABLEASSIGNER_GLUE_WEAK(this, "nodeIconAd", cocos2d::Node*, BulldogMapIconAdLayer::nodeIconAd);
-
- return false;
- }
- SEL_MenuHandler BulldogMapIconAdLayer::onResolveREDCCMenuItemSelector(Ref * pTarget, const char* pSelectorName){return nullptr;}
- cocos2d::extension::Control::Handler BulldogMapIconAdLayer::onResolveREDCCControlSelector(cocos2d::Ref * pTarget, const char* pSelectorName){
- RED_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onOpenClick", BulldogMapIconAdLayer::onOpenClick);
- // RED_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onCloseClick", BulldogMapIconAdLayer::onCloseClick);
- return NULL;
- }
- void BulldogMapIconAdLayer::setAnimationManager(redream::REDAnimationManager* mgr){
- CC_SAFE_RELEASE_NULL(this->amgr);
- this->amgr = mgr;
-
- amgr->setDelegate(this);
-
- CC_SAFE_RETAIN(this->amgr);
-
- }
- void BulldogMapIconAdLayer::setContent(){
-
- }
- void BulldogMapIconAdLayer::completedAnimationSequenceNamed(const char *name, int seqId,int tag){
- // if(strcmp(name, "close") == 0){
- //
- // removeFromParent();
- //
- // }
- }
- void BulldogMapIconAdLayer::onNodeLoaded(Node * pNode, redream::NodeLoader * pNodeLoader){
- // PFCloseTouch(this);
- // if(layerWrapper){
- // CoreFunc::SmartScaleHeightNoContentSize(layerWrapper);
- // }
- // setLocalZOrder(999999);
- // setGlobalZOrder(999999);
- // removeFromParentAndCleanup(false);
- // Director::getInstance()->getRunningScene()->addChild(this, 999999);
- // EventListenerTouchOneByOne* listen = EventListenerTouchOneByOne::create();
- // listen->setSwallowTouches(true);
- // listen->onTouchBegan = CC_CALLBACK_2(BrickGameLayer::onTouchBegan, this);
- // listen->onTouchMoved = CC_CALLBACK_2(BrickGameLayer::onTouchMoved, this);
- // listen->onTouchEnded = CC_CALLBACK_2(BrickGameLayer::onTouchEnded, this);
-
- // _bulldogAdsMaplisten = EventListenerTouchOneByOne::create();
- // auto callback = [this](Touch * touch,Event *)
- // {
- //
- //// CCLOG("MapIconAd_touch:%f,%f",touch->getLocation().x,touch->getLocation().y);
- // Vec2 point = convertTouchToNodeSpace(touch);
- //// CCLOG("MapIconAd_point:%f,%f",point.x,point.y);
- // if(point.x<0 || point.y<0 || point.x>getContentSize().width || point.y>getContentSize().height){
- // return false;
- // }
- //
- // RedAdLayerController::getInstance()->openIconAdLayer();
- //
- // return true;
- // };
- // _bulldogAdsMaplisten->onTouchBegan = callback;
- // _bulldogAdsMaplisten->setSwallowTouches(true);
- //// Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listen, this);
- // Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_bulldogAdsMaplisten, -999999);
- }
- void BulldogMapIconAdLayer::onOpenClick(Ref * pSender,cocos2d::extension::Control::EventType pEvent){
- // BulldogAd* ad = BulldogIconAdController::getInstance()->getBulldogAd();
- // int index = BulldogIconAdController::getInstance()->getCurShowAdIndex();
- RedAdLayerController::getInstance()->openIconAdLayer();
-
- }
- //void BulldogMapIconAdLayer::onCloseClick(Ref * pSender,cocos2d::extension::Control::EventType pEvent){
- //// btnClose->setEnabled(false);
- //// amgr->runAnimationsForSequenceNamed("close");
- ////
- //// RedAdLayerController::getInstance()->closeInterstitial();
- //// Sound::Shared()->resumeBackgroundMusic();
- //
- //
- //}
- void BulldogMapIconAdLayer::onExit() {
- Layer::onExit();
- amgr->setDelegate(NULL);
- }
- void BulldogMapIconAdLayer::onEnter(){
- Layer::onEnter();
- Ref* obj = this->getUserObject();
- redream::REDAnimationManager * ret = dynamic_cast<redream::REDAnimationManager*>(obj);
- setAnimationManager(ret);
-
- setContent();
- IconCcbiPathData iconData = BulldogIconAdController::getInstance()->getNextIconPath();
- if(iconData.plistPath==""){
- setVisible(false);
- return;
- }
-
- SpriteFrameCache::getInstance()->addSpriteFramesWithFile(iconData.plistPath);
- BulldogIconLayer* bulldogIconLayer = BulldogIconLayer::Layer(iconData.ccbiPath);
-
- if(bulldogIconLayer==nullptr){
- setVisible(false);
- return;
- }
-
- nodeIconAd->removeAllChildren();
- bulldogIconLayer->toParentLayer(nodeIconAd);
- setVisible(true);
- }
- BulldogMapIconAdLayer::~BulldogMapIconAdLayer()
- {
- // Director::getInstance()->getEventDispatcher()->removeEventListener(_bulldogAdsMaplisten);
- CC_SAFE_RELEASE_NULL(this->amgr);
- }
- BulldogMapIconAdLayer::BulldogMapIconAdLayer()
- {
- amgr = NULL;
- _bulldogAdsMaplisten = nullptr;
- }
- NS_RU_END
|