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的更多相关文章
随机推荐
- 深入理解Apache Flink核心技术
深入理解Apache Flink核心技术 2016年02月18日 17:04:03 阅读数:1936 标签: Apache-Flink数据流程序员JVM 版权声明:本文为博主原创文章,未经博主允许 ...
- KB/KiB,MB/MiB,GB/GiB了解一下
Kibibyte是一种资讯计量单位,代表1024字节,即210字节,一般简称为KiB.Kibibyte是来自英文 kilo binary byte 的缩写,意思为“千位二进制字节”. 而KB是kilo ...
- docker学习总结--安装、卸载
参考:http://blog.csdn.net/u012562943/article/details/50463400 https://docs.docker.com/engine/getstarte ...
- axure 6.5 汉化正式版软件及注册码
Axure公司发布了Axure RP 6.5 正式版. 官方主页: http://www.axure.com/news 官方下载: http://www.axure.com/download 视频介绍 ...
- Computer Generated Angular Fisheye Projections [转]
Computer GeneratedAngular Fisheye Projections Written by Paul Bourke May 2001 There are two main ide ...
- 查看网络IP连接
- java常用公共代码二之分页代码的实现
在项目中,我们经常会写到一些公共的代码,来让开发人员调用,减少代码重复,下面,我就将一些常用到的公共类贴出来和大家分享!! 二.分页代码实现:在项目中,分页是一个项目中必不可少的,它可以防止我们从数据 ...
- RS查询报错之递归公用表表达式不包含顶级 UNION ALL运算符
在FM里面涉及模型的时候,修改了物理层的查询SQL如下 select * from TARGET_VISIT_GH where ghksdm in(select dept_id from DIM_BI ...
- RDLC 动态列
很久没有写博客了,关于动态列,国内很少资料有介绍动态列的,所想写点心得给哥们 啥是动态列呢?通常我们用存储过程时有列转行和行转列的做法,那么在RDLC 怎么支持呢?其实很简单,就是利用了RDLC的 C ...
- Generator [ˈdʒenəreɪtə(r)] 函数结构
Generator函数是ES6新增的一种异步编程方案. 说明:Generator函数指的是一种新的语法结构,是一个遍历器对象生成器,它内部可以封装多个状态,非常适合用于异步操作. Generator函 ...