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的更多相关文章
随机推荐
- matlab 人面检测
Create a detector object. faceDetector = vision.CascadeObjectDetector;Read input image. I = imread(' ...
- MFC DLL对话框调用
Regular Dll using shared MFC DLL extern "C" __declspec(dllexport) void Show() { AFX_MANA ...
- slf4j log4j logback log4j2关系详解和相关用法
来源:slf4j log4j logback关系详解和相关用法https://www.cnblogs.com/Sinte-Beuve/p/5758971.html The Simple Logging ...
- 《纵向切入ASP.NET 3.5控件和组件开发技术》笔记:高效率事件集合对象
在之前讲的几个例子中,使用的是最普通的定义事件方法,比如KingTextBox中事件是这样定义的:/// <summary>/// 获得本书更多内容,请看:/// http://blog. ...
- Sqlserver 使用CTE如何按子查询排序?
需求:查出最近有更改的客户信息(按最后更改时间排序,来自SystemLog表LogDateTime字段) 说明: Customer:客户信息表SystemLog:系统日志表,记录所有表信息的增,删,改 ...
- Open DJ备份与恢复方案
最近接手了一个Cognos项目,第三方用户认证采用的是和Open DJ集成.本人之前很多采用的是cjap ,当然这和cjap相比起来简单的多了,最起码你不必具有Java的基础知识就可以完全驾驭了! 一 ...
- [Firebase] 4. Firebase Object related Database
The idea: This post we are going to learn how to build a Firebase Forage with object related databas ...
- (笔试题)N!尾部连续0的个数
题目: 对任意输入的正整数N,编写C程序求N!的尾部连续0的个数,并指出计算复杂度.如:18!=6402373705728000,尾部连续0的个数是3. (不用考虑数值超出计算机整数界限的问题) 思路 ...
- Android编译程序报错:Re-installation failed due to different application signatures.
如果机子上已经安装非本机编译的android程序,在编译的时候就会报错.方法首选的是删除原程序,然后再进行编译. 但是有一部分程序是烧录在系统程序里面的,无法直接删除,这时候可以使用adb shell ...
- JUnit 3.8 通过反射测试私有方法
测试私有(private)的方法有两种: 1)把目标类的私有方法(修饰符:private)修改为(public),不推荐,因为修改了源程序不佳 2)通过反射 (推荐) 代码演示: 目标程序 Priva ...