• Cocos2dx 中的点击事件


    简单记录一下2dx的鼠标交互事件。以及精灵绑定盒的点击判定
     
    Layer 子类的 init方法中:
     
    auto listener = EventListenerTouchOneByOne::create();//
     listener->onTouchBegan = CC_CALLBACK_2(GameMenuScene::touchBegin,this);
    _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
    

      

     
    Layer子类源文件中:
      bool GameMenuScene::touchBegin(CCTouch * touch,CCEvent *event)
       {
          CCPoint pt =  touch->getLocationInView();
     
          pt = Director::getInstance()->convertToGL(pt);
     
         if(sprite->getBoundingBox().containsPoint(pt))
         {
             CCLog("CLick");
          }
     
          return true;
       }
    

      

  • 相关阅读:
    shell:bash基本特性
    python_day02
    python_day01
    centos环境下安装python3以及pip3
    http1到http3的巨大变化
    HTTP协议
    bootstrap
    JQuery
    BOM与DOM
    23种设计模式的几种常见的设计模式
  • 原文地址:https://www.cnblogs.com/xyida/p/4305947.html
Copyright © 2020-2023  润新知