[求教]关于cocos2dx3.1.1中ControlButton的方法addTargetWithActionForControlEvents

ae5555 2014-07-05 10:29:56
我是新手,刚开始学cocos2dx。
ControlButton的addTargetWithActionForControlEvents
在v2.x中应该是这样的:
addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::buttonleft), CCControlEventTouchDown);

但是在v3.1.1中,我用的VS2013,CCControlEventTouchDown这一类型不识别,看了下源码原来是改成这样了
enum class EventType
{
TOUCH_DOWN = 1 << 0, // A touch-down event in the control.
DRAG_INSIDE = 1 << 1, // An event where a finger is dragged inside the bounds of the control.
DRAG_OUTSIDE = 1 << 2, // An event where a finger is dragged just outside the bounds of the control.
DRAG_ENTER = 1 << 3, // An event where a finger is dragged into the bounds of the control.
DRAG_EXIT = 1 << 4, // An event where a finger is dragged from within a control to outside its bounds.
TOUCH_UP_INSIDE = 1 << 5, // A touch-up event in the control where the finger is inside the bounds of the control.
TOUCH_UP_OUTSIDE = 1 << 6, // A touch-up event in the control where the finger is outside the bounds of the control.
TOUCH_CANCEL = 1 << 7, // A system event canceling the current touches for the control.
VALUE_CHANGED = 1 << 8 // A touch dragging or otherwise manipulating a control, causing it to emit a series of different values.
};

所以我就把那个事件类型改了一下
addTargetWithActionForControlEvents(this,cccontrol_selector(HelloWorld::buttonleft), Control::EventType::TOUCH_DOWN);

系统没有提示错误,但是编译的时候就提示
1>f:\coco2dx\mygame\classes\HelloWorldScene.h(20): error C2653: “Control”: 不是类或命名空间名称 (..\Classes\AppDelegate.cpp)
1>f:\coco2dx\mygame\classes\HelloWorldScene.h(20): error C2061: 语法错误: 标识符“EventType” (..\Classes\AppDelegate.cpp)
头文件和命名空间我都加了的,但就是编译的时候出了问题。请高手帮我看一下。
...全文
887 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
威威猫Alter 2014-07-22
  • 打赏
  • 举报
回复
请问你怎么看到那个源代码的?我没找到
ae5555 2014-07-07
  • 打赏
  • 举报
回复
原来要把包含的头文件放到头文件中。。。太大意了

80,352

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧