码迷,mamicode.com
首页 > 其他好文 > 详细

Cocos2dx 中的点击事件

时间:2015-02-28 18:14:47      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:

简单记录一下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;
   }

  

Cocos2dx 中的点击事件

标签:

原文地址:http://www.cnblogs.com/xyida/p/4305947.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!