win32的api实在太麻烦了,但是glView里面有个setCursorVisible的方法,可是借此实现同样的效果。
AppDelegate.cpp中:
glview =@H_301_7@ GLViewImpl::createWithFullScreen@H_301_7@("123465"@H_301_7@);
glview->@H_301_7@setCursorVisible(false@H_301_7@);
director->@H_301_7@setOpenGLView(glview);
自己的layer中:
//鼠标指针
auto@H_301_7@ cursor = Sprite@H_301_7@::create("cursor_nor.png"@H_301_7@);
this@H_301_7@->_cursor = Node@H_301_7@::create();
this@H_301_7@->_cursor->addChild(cursor);
this@H_301_7@->addChild(this->_cursor,10000@H_301_7@);
auto@H_301_7@ listenerMouse = EventListenerMouse@H_301_7@::create();
listenerMouse->onMouseMove = [&](cocos2d::EventMouse@H_301_7@* event) {
Point@H_301_7@ mouse = event->getLocation();
mouse.y = 1024@H_301_7@ - mouse.y;
this->_cursor->setPosition(Point@H_301_7@(mouse.x+20@H_301_7@,mouse.y-30@H_301_7@));
};
listenerMouse->onMouseDown = [&](cocos2d::EventMouse@H_301_7@* event) {
this->_cursor->removeAllChildren();
auto cursor = Sprite@H_301_7@::create("cursor_pre.png"@H_301_7@);
this->_cursor->addChild(cursor);
};
listenerMouse->onMouseUp = [&](cocos2d::EventMouse@H_301_7@* event) {
this->_cursor->removeAllChildren();
auto cursor = Sprite@H_301_7@::create("cursor_nor.png"@H_301_7@);
this->_cursor->addChild(cursor);
};
this->_eventDispatcher->addEventListenerWithFixedPriority(listenerMouse,1@H_301_7@);