RUBulldogGameOverIconAdCell.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //
  2. // BulldogGameOverIconAdCell.cpp
  3. // BubbleShoot
  4. //
  5. // Created by 刘玉涛 on 17/9/1.
  6. //
  7. //
  8. #include "RUBulldogGameOverIconAdCell.h"
  9. #include "BulldogIconLayer.h"
  10. NS_RU_BEGIN
  11. BulldogGameOverIconAdCell * BulldogGameOverIconAdCell::Layer(){
  12. redream::NodeLoaderLibrary *lib = redream::NodeLoaderLibrary::newDefaultNodeLoaderLibrary();
  13. lib->registerNodeLoader("BulldogGameOverIconAdCell", BulldogGameOverIconAdCellLoader::loader());
  14. redream::REDReader *reader = new(std::nothrow) redream::REDReader(lib);
  15. reader->autorelease();
  16. BulldogGameOverIconAdCell * node = (BulldogGameOverIconAdCell*)reader->readNodeGraphFromFile("BulldogGameOverIconAdCell.redream");
  17. return node;
  18. }
  19. bool BulldogGameOverIconAdCell::onAssignREDMemberVariable(Ref* pTarget, const char* pMemberVariableName, Node* pNode){
  20. RED_MEMBERVARIABLEASSIGNER_GLUE_WEAK(this, "nodeIconAd", cocos2d::Node*, BulldogGameOverIconAdCell::nodeIconAd);
  21. return false;
  22. }
  23. SEL_MenuHandler BulldogGameOverIconAdCell::onResolveREDCCMenuItemSelector(Ref * pTarget, const char* pSelectorName){return nullptr;}
  24. cocos2d::extension::Control::Handler BulldogGameOverIconAdCell::onResolveREDCCControlSelector(cocos2d::Ref * pTarget, const char* pSelectorName){
  25. return NULL;
  26. }
  27. void BulldogGameOverIconAdCell::setAnimationManager(redream::REDAnimationManager* mgr){
  28. CC_SAFE_RELEASE_NULL(this->amgr);
  29. this->amgr = mgr;
  30. amgr->setDelegate(this);
  31. CC_SAFE_RETAIN(this->amgr);
  32. }
  33. void BulldogGameOverIconAdCell::setContent(string ccbiPath){
  34. BulldogIconLayer* bulldogIconLayer = BulldogIconLayer::Layer(ccbiPath);
  35. if(bulldogIconLayer){
  36. setVisible(true);
  37. bulldogIconLayer->toParentLayer(nodeIconAd);
  38. // float scale = nodeIconAd->getContentSize().width/bulldogIconLayer->getContentSize().width;
  39. // bulldogIconLayer->setScale(scale);
  40. // bulldogIconLayer->setPosition(nodeIconAd->getContentSize()*0.5);
  41. // ->addChild(bulldogIconLayer);
  42. }
  43. }
  44. void BulldogGameOverIconAdCell::completedAnimationSequenceNamed(const char *name, int seqId,int tag){
  45. if(strcmp(name, "close") == 0){
  46. removeFromParent();
  47. }
  48. }
  49. void BulldogGameOverIconAdCell::onNodeLoaded(Node * pNode, redream::NodeLoader * pNodeLoader){
  50. }
  51. void BulldogGameOverIconAdCell::onDownloadClick(Ref * pSender,cocos2d::extension::Control::EventType pEvent){
  52. // RedAdLayerController::getInstance()->clickInterstitial();
  53. }
  54. void BulldogGameOverIconAdCell::onCloseClick(Ref * pSender,cocos2d::extension::Control::EventType pEvent){
  55. // btnClose->setEnabled(false);
  56. // amgr->runAnimationsForSequenceNamed("close");
  57. //
  58. // RedAdLayerController::getInstance()->closeInterstitial();
  59. // Sound::Shared()->resumeBackgroundMusic();
  60. }
  61. void BulldogGameOverIconAdCell::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
  62. {
  63. TableViewCell::draw(renderer, transform, flags);
  64. // draw bounding box
  65. // auto pos = getPosition();
  66. // auto size = Size(178, 200);
  67. // Vec2 vertices[4]={
  68. // Vec2(pos.x+1, pos.y+1),
  69. // Vec2(pos.x+size.width-1, pos.y+1),
  70. // Vec2(pos.x+size.width-1, pos.y+size.height-1),
  71. // Vec2(pos.x+1, pos.y+size.height-1),
  72. // };
  73. // DrawPrimitives::drawColor4B(0, 0, 255, 255);
  74. // DrawPrimitives::drawPoly(vertices, 4, true);
  75. }
  76. void BulldogGameOverIconAdCell::onExit() {
  77. Node::onExit();
  78. amgr->setDelegate(NULL);
  79. }
  80. void BulldogGameOverIconAdCell::onEnter(){
  81. Node::onEnter();
  82. Ref* obj = this->getUserObject();
  83. redream::REDAnimationManager * ret = dynamic_cast<redream::REDAnimationManager*>(obj);
  84. setAnimationManager(ret);
  85. }
  86. BulldogGameOverIconAdCell::~BulldogGameOverIconAdCell(){
  87. CC_SAFE_RELEASE_NULL(this->amgr);
  88. }
  89. BulldogGameOverIconAdCell::BulldogGameOverIconAdCell()
  90. :amgr(NULL)
  91. {
  92. amgr = NULL;
  93. }
  94. NS_RU_END