CControlLayer
#ifndef __CONTROLLAYER_H__
#define __CONTROLLAYER_H__ #include "XWidget.h" class CMapDialog;
class CXTimer;
class CTowerDialog; class CControlLayer : public CXWidget
{
public:
enum ControlLayerId
{
_IDD_ControLyaer = ,
};
public:
CControlLayer();
~CControlLayer(); virtual bool init(); virtual bool onMouseDown(CCTouch *pTouch, CCEvent *pEvent);
virtual void onMouseUp(CCTouch *pTouch, CCEvent *pEvent);
virtual void onMouseMove(CCTouch *pTouch, CCEvent *pEvent); void onTimerEnd(CCObject* obj);
private:
int m_nTimerCount;
bool m_bDblclick; CCPoint m_tMoveDist;
CMapDialog* m_pMapDlg;
CXTimer* m_pTimer;
CTowerDialog* m_pTowerDlg; }; #endif
#include "ControlLayer.h"
#include "WidgetMgr.h"
#include "GameLogic.h"
#include "MapDialog.h"
#include "XTimer.h"
#include "Dispatcher.h" CControlLayer::CControlLayer()
{
m_tMoveDist.setPoint(, );
m_pMapDlg = NULL;
m_bDblclick = false;
m_pTimer = NULL;
m_pTowerDlg = NULL;
} CControlLayer::~CControlLayer()
{ } bool CControlLayer::init()
{
CWidgetMgr::getInstance()->loadWidget(this, _IDD_ControLyaer);
CWidgetMgr::getInstance()->addWnd(this); this->setTouchEnabled(true); m_pTimer = new CXTimer();
m_pTimer->init(, 0.1f);
m_pTimer->autorelease();
this->addChild(m_pTimer);
m_pTimer->setTimerEndListener(this, callfuncO_selector(CControlLayer::onTimerEnd)); return true;
} bool CControlLayer::onMouseDown( CCTouch *pTouch, CCEvent *pEvent )
{
CCPoint tMouseDownPos = pTouch->getLocationInView();
tMouseDownPos = CCDirector::sharedDirector()->convertToGL(tMouseDownPos);
tMouseDownPos = this->convertToNodeSpace(tMouseDownPos); CDispatcher::getInstance()->onMoveDown(tMouseDownPos); if (m_bDblclick)
{//双击
if (1.0f == CDispatcher::getInstance()->getWorldScale())
{
CDispatcher::getInstance()->setWorldScale(1.5f);
}
else
{
CDispatcher::getInstance()->setWorldScale(1.0f);
}
} if (m_pTimer)
{
m_pTimer->setCount();
m_pTimer->start();
m_bDblclick = true;
} return true;
} void CControlLayer::onMouseUp( CCTouch *pTouch, CCEvent *pEvent )
{
CCPoint tMouseUpPos = pTouch->getLocationInView();
tMouseUpPos = CCDirector::sharedDirector()->convertToGL(tMouseUpPos);
tMouseUpPos = this->convertToNodeSpace(tMouseUpPos); } void CControlLayer::onMouseMove( CCTouch *pTouch, CCEvent *pEvent )
{
CCPoint moveCurPos = pTouch->getLocationInView();
moveCurPos = CCDirector::sharedDirector()->convertToGL(moveCurPos);
moveCurPos = this->convertToNodeSpace(moveCurPos);
CCPoint movePrevPos = pTouch->getPreviousLocationInView();
movePrevPos = CCDirector::sharedDirector()->convertToGL(movePrevPos);
movePrevPos = this->convertToNodeSpace(movePrevPos); m_tMoveDist.setPoint(moveCurPos.x - movePrevPos.x, moveCurPos.y - movePrevPos.y); CDispatcher::getInstance()->onMoveDist(m_tMoveDist); } void CControlLayer::onTimerEnd( CCObject* obj )
{
m_bDblclick = false;
}
CControlLayer的更多相关文章
随机推荐
- linux查看进程信息 so依赖
查看进程ps -A PID进程的sopmap -x pid
- OpenCV学习(4) Mat的基本操作(1)
图像在OpenCV中都是通过Mat类来存储的,Mat可以用来表示N维矩阵,当然用的最多的还是二维矩阵. Mat类有两部分组成:第一部分是头信息,这些信息主要用来描述矩阵,比如矩 ...
- java常用公共代码二之分页代码的实现
在项目中,我们经常会写到一些公共的代码,来让开发人员调用,减少代码重复,下面,我就将一些常用到的公共类贴出来和大家分享!! 二.分页代码实现:在项目中,分页是一个项目中必不可少的,它可以防止我们从数据 ...
- 那些年困扰我们的Linux 的蠕虫、病毒和木马
虽然针对Linux的恶意软件并不像针对Windows乃至OS X那样普遍,但是近些年来,Linux面临的安全威胁却变得越来越多.越来越严重.个中原因包括,手机爆炸性的普及意味着基于Linux的安卓成为 ...
- [Functional Programming] Write simple Semigroups type
An introduction to concatting items via the formal Semi-group interface. Semi-groups are simply a ty ...
- gem 更新源设置,ruby安装
gem sources --remove http://rubygems.org/ gem sources -a http://ruby.taobao.org/ gem sources -l 结果只有 ...
- [置顶] ArcGIS Runtime SDKs 10.2 for iOS & Android& OS X发布
我们高兴的宣布:ArcGISRuntime SDKs 10.2 for iOS & Android & OS X正式发布!在10.2版本中,你可以在iOS.Android和Mac设备上 ...
- keytool命令总结
keytool 命令总结 一.创建数字证书 交互模式 使用默认的密钥库.keystore(目录是c: Documents and Setting用户名)和算法(DSA) keytool -genkey ...
- profiler跟踪事件存为表之后性能分析工具
使用profiler建立跟踪,将跟踪结果存到表中,使用下面存储过程执行 exec temp_profiler 'tra_tablename'对表数据进行处理归类,然后进行性能分析 1.先建存储过程 2 ...
- [Exception JavaWeb 1] - Cause: com.microsoft.sqlserver.jdbc.SQLServerException: '@P2' 附近有语法错误。
严重: Servlet.service() for servlet [springMVC] in context with path [/ExceptionManageSystem] threw ex ...