void MouseTest::onMouseDown(Event *event){
EventMouse* e = (EventMouse*)event;
string str = "Mouse Down detected, Key: ";
str += tostr(e->getMouseButton());
}
其中str += tostr(e->getMouseButton());这行代码是什么意思?
void MouseTest::onMouseDown(Event *event){
EventMouse* e = (EventMouse*)event;
string str = "Mouse Down detected, Key: ";
str += tostr(e->getMouseButton());
}
其中str += tostr(e->getMouseButton());这行代码是什么意思?
就是str变成上面那一句加上那个函数返回的值
那个tostr(e->getMouseButton())函数返回的是一个什么样的值?
显示tostr是一个未定义标识符,
tostr 从字面来看就是toString, getMouseButton返回的是button,而不是str,需转为字符串,如果tostr未定义,自己写一下
这个问题如何解决?
2>d:\cocos2d-x-3.5\tests\game1\classes\helloworldscene.cpp(203): error C2065: “BUTTON_LEFT”: undeclared identifier
2>d:\cocos2d-x-3.5\tests\game1\classes\helloworldscene.cpp(204): error C2065: “button”: undeclared identifier
2>d:\cocos2d-x-3.5\tests\game1\classes\helloworldscene.cpp(204): error C3083: “MouseButton”: The symbol on the left side of “::” must be a type
2>d:\cocos2d-x-3.5\tests\game1\classes\helloworldscene.cpp(204): error C2039: “BUTTON_RIGHT”: not a member of “cocos2d::EventMouse”
2> d:\cocos2d-x-3.5\tests\game1\cocos2d\cocos\base\cceventmouse.h(51): see the declaration of “cocos2d::EventMouse”
???你是不是不会c++呀,switch下面的三行代码前面的case呢?或者你的本意是这三行代码应该在switch之前?
估计是网上抄的代码,看不懂然后还报错就来问了,c++语法可能都没看
你这是一门编程语言都没学过吧,你这样无穷无尽的问还不如先去学学语言。
大兄弟, 听我一句劝, 先去学语言语法吧,这都不到引擎这一级