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的更多相关文章
随机推荐
- OpenCV学习(4) Mat的基本操作(1)
图像在OpenCV中都是通过Mat类来存储的,Mat可以用来表示N维矩阵,当然用的最多的还是二维矩阵. Mat类有两部分组成:第一部分是头信息,这些信息主要用来描述矩阵,比如矩 ...
- HDU 1232 (13.10.31)
畅通工程 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...
- boost.asio学习笔记一、linux下boost库的安装
欢迎转载,转载请注明原文地址:http://blog.csdn.net/majianfei1023/article/details/46761029 学习开源库第一步就是编译安装好库,然后执行成功一个 ...
- [CF 295A]Grag and Array[差分数列]
题意: 有数列a[ ]; 操作op[ ] = { l, r, d }; 询问q[ ] = { x, y }; 操作表示对a的[ l, r ] 区间上每个数增加d; 询问表示执行[ x, y ]之间的o ...
- [Angular-Scaled web] 5. ui-router $stateParams for sharing information
When using ui-route, we want to pass the information with the url. Example: angular.module('categori ...
- (LeetCode 49)Anagrams
Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be ...
- Iocomp控件教程之Pie Chart——饼状图控件
Pie Chart--饼状图控件(Pie Chart)以饼状图形式显示每一个项目内容所占的百分比比重.在设计时.能够使用属性编辑器加入或者移除项目以及更改属性值.在执行时.使用AddItem,Remo ...
- HDU 4757
可持久化trie树.不会可持久化数据结构的话推荐先看陈立杰的论文.先掌握可持久化线段树和可持久化trie树. //可持久化trie树,题目已知一棵树,每个点有点权,询问一对点路径上点权与给定值异或的最 ...
- 如何知道TSQL语句已经运行了多久
如何知道TSQL语句已经运行了多久 ,) --millisecond per tick --如果datediff 函数导致溢出 把下面的millisecond改为second 毫秒改为秒 SELECT ...
- 偏最小二乘回归(PLSR)- 2 标准算法(NIPALS)
1 NIPALS 算法 Step1:对原始数据X和Y进行中心化,得到X0和Y0.从Y0中选择一列作为u1,一般选择方差最大的那一列. 注:这是为了后面计算方便,如计算协方差时,对于标准化后的数据,其样 ...