win32的api实在太麻烦了,但是glView里面有个setCursorVisible的方法,可是借此实现同样的效果。
AppDelegate.cpp中:
glview = GLViewImpl::createWithFullScreen("123465");
glview->setCursorVisible(false);
director->setopenGLView(glview);
自己的layer中:
//鼠标指针
auto cursor = Sprite::create("cursor_nor.png");
this->_cursor = Node::create();
this->_cursor->addChild(cursor);
this->addChild(this->_cursor,10000);
auto listenerMouse = EventListenerMouse::create();
listenerMouse->onMouseMove = [&](cocos2d::EventMouse* event) {
Point mouse = event->getLocation();
mouse.y = 1024 - mouse.y;
this->_cursor->setPosition(Point(mouse.x+20,mouse.y-30));
};
listenerMouse->onMouseDown = [&](cocos2d::EventMouse* event) {
this->_cursor->removeAllChildren();
auto cursor = Sprite::create("cursor_pre.png");
this->_cursor->addChild(cursor);
};
listenerMouse->onmouseup = [&](cocos2d::EventMouse* event) {
this->_cursor->removeAllChildren();
auto cursor = Sprite::create("cursor_nor.png");
this->_cursor->addChild(cursor);
};
this->_eventdispatcher->addEventListenerWithFixedPriority(listenerMouse,1);
原文地址:https://www.jb51.cc/cocos2dx/340534.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。