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的更多相关文章
随机推荐
- 升级struts到2.5.2遇到的问题及解决方案
原来的版本是2.3.x,由于安全原因需要升级到2.5.2.1,2.5.2版本不再提供xwork.jar ,整合到了 struts-core包中. 2,方法不能访问的问题,需要在每个action配置文件 ...
- OpenCV学习(11) 图像的腐蚀与膨胀(2)
先对一副灰度图像进行腐蚀操作,然后在腐蚀后的图像上再进行膨胀操作,我们定义这个操作为开操作. 先对一副图像进行膨胀操作,然后在膨胀后的图像上再进行腐蚀操作,我们定义这个操作为闭操作. 开操 ...
- Proxmark3介绍
Proxmark3介绍 Proxmark3是由Jonathan Westhues设计并且开发的开源硬件,其主要用RFID的嗅探.读取以及克隆等的操作. 其官方网站为:Jonathan Westhues ...
- php 中array_multisort排序,类似于对数据库中的记录依次按多列进行排序
array_multisort这个函数还是很有用的. ------------------------------------------------------------------------- ...
- tm标准mvc框架对应robotlegs 的mvc
tm标准mvc框架对应robotlegs 的mvc+s (其实都是一样样滴)
- UVA11402 - Ahoy, Pirates!(线段树)
UVA11402 - Ahoy, Pirates!(线段树) option=com_onlinejudge&Itemid=8&category=24&page=show_pro ...
- 使用JavaMelody监控tomcat以及jvm
JavaMelody用于对Java应用或者应用服务器的QA以及开发环境的监控.它并不是一个模拟请求类似JMeter的压力测试工具,而是一个衡量并且计算在应用上的操作信息的工具,也就是说,它只负责对行为 ...
- 自己定义UIView以实现自绘
有时候我们须要自绘uiview以实现自己的需求,比方依据坐标点绘制出连续的曲线(股票走势图),就须要自绘uiview了. 原理:继承uiview类(customView),并实现custom view ...
- Tags Used In OpenERP 7.0
In OpenERP 7.0. the form view of each object has been redesigned so that the object the user is work ...
- 从头认识多线程-1.9 迫使线程停止的方法-return法
这一章节我们来讨论一下还有一种停止线程的方法-return 1.在主线程上面return,是把全部在执行的线程都停掉 package com.ray.deepintothread.ch01.topic ...