本文整理汇总了C++中EventMouse::getScrollY方法的典型用法代码示例。如果您正苦于以下问题:C++ EventMouse::getScrollY方法的具体用法?C++ EventMouse::getScrollY怎么用?C++ EventMouse::getScrollY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventMouse
的用法示例。
在下文中一共展示了EventMouse::getScrollY方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onMouseScroll
///Input is 1 or -1
void HelloWorld::onMouseScroll(Event* event)
{
#ifdef MOUSE_DOUBLE_LISTEN_FUDGE
mouseScrollFudge = !mouseScrollFudge;
if(!mouseScrollFudge)
return;
#endif
EventMouse* e = (EventMouse*)event;
if(e->getScrollY() > 0)
{
auto vect = screenspaceToWorldspace(lastCursor);
}
else if(e->getScrollY() < 0)
{
}
}
示例2: onMouseScroll
void MouseTest::onMouseScroll(Event *event)
{
EventMouse* e = (EventMouse*)event;
std::string str = "Mouse Scroll detected, X: ";
str = str + tostr(e->getScrollX()) + " Y: " + tostr(e->getScrollY());
_labelAction->setString(str.c_str());
}
示例3: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
if ( !Layer::init() )
{
return false;
}
FileUtils::getInstance()->addSearchPath("../QtCocos2d/Resources");
FileUtils::getInstance()->addSearchResolutionsOrder("resource-auto");
Director::getInstance()->setContentScaleFactor(2.0f);
Director::getInstance()->setAnimationInterval(FLT_MIN);
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
auto centerNode = Node::create();
centerNode->setAnchorPoint(Point::ANCHOR_MIDDLE);
// centerNode->setContentSize(visibleSize);
centerNode->setPosition(origin + visibleSize/2);
this->addChild(centerNode);
auto frame = Sprite::create("system/frame_iphone4.png");
frame->setAnchorPoint(Point::ANCHOR_MIDDLE);
centerNode->addChild(frame);
auto worldPos = centerNode->convertToWorldSpace(frame->getPosition());
qDebug() << worldPos.x << "," << worldPos.y;
auto listener = EventListenerMouse::create();
listener->onMouseScroll = [this, frame](Event* event){
EventMouse *e = dynamic_cast<EventMouse *>(event);
if (NULL != e)
{
float scrollY = e->getScrollY();
frame->setScale(scrollY / 10.0f + frame->getScale());
}
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
auto baseNode = Node::create();
baseNode->setContentSize(Size(480, 320));
baseNode->setPosition(baseNode->getContentSize() / -2 + frame->getContentSize()/2);
frame->addChild(baseNode);
worldPos = frame->convertToWorldSpace(baseNode->getPosition());
qDebug() << worldPos.x << "," << worldPos.y;
/*
ControlButton * button = ControlButton::create();
button->setTitleLabelForState(Label::createWithSystemFont("aaa", "MS Gothic", 12), Control::State::NORMAL);
baseNode->addChild(button);
*/
_metaInfo = InterfaceLoader::getInstance().loadJSon("interface/scene/scenetest.json");
if (_metaInfo)
{
_metaInfo->retain();
baseNode->addChild(_metaInfo->getBaseNode());
}
return true;
}
示例4: onMouseScroll
void ScreenTest::onMouseScroll(Event *event)
{
EventMouse* e = (EventMouse*)event;
float scrolly = e->getScrollY();
m_scale += scrolly / 10;
if(m_scale < 0)
{
m_scale = 0;
}
refeshInfo();
}
示例5: onMouseScroll
void MenuScene::onMouseScroll(Event * event)
{
EventMouse * mouseEvent = static_cast<EventMouse *>(event);
float deltaY = mouseEvent->getScrollY() * 6;
this->moveMenuBy(deltaY);
}
示例6: init
//.........这里部分代码省略.........
break;
case EventKeyboard::KeyCode::KEY_D:
case EventKeyboard::KeyCode::KEY_CAPITAL_D:
CCLOG("key D up");
_right = false;
break;
case EventKeyboard::KeyCode::KEY_Q:
case EventKeyboard::KeyCode::KEY_CAPITAL_Q:
CCLOG("key Q up");
_up = false;
break;
case EventKeyboard::KeyCode::KEY_E:
case EventKeyboard::KeyCode::KEY_CAPITAL_E:
CCLOG("key E up");
_down = false;
break;
// case EventKeyboard::KeyCode::KEY_UP_ARROW:
// up();
// break;
// case EventKeyboard::KeyCode::KEY_DOWN_ARROW:
// down();
// break;
// case EventKeyboard::KeyCode::KEY_LEFT_ARROW:
// left();
// break;
// case EventKeyboard::KeyCode::KEY_RIGHT_ARROW:
// right();
// break;
default:
break;
}
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(_keyboardListener, this);
// mouse
_mouseListener = EventListenerMouse::create();
_mouseListener->onMouseMove = [&](Event *event) {
if (!_isFPS) return;
EventMouse* e = (EventMouse*)event;
auto now = e->getLocation();
Vec2 diff = now - _fpsAnchor;
_fpsAnchor = now;
_rotateY -= ROTATE_SCALE*diff.x;
_rotateX -= ROTATE_SCALE*diff.y;
if (_rotateX > UP_DOWN_MAX*0.5f*PI) _rotateX = UP_DOWN_MAX*0.5f*PI;
if (_rotateX < -UP_DOWN_MAX*0.5f*PI) _rotateX = -UP_DOWN_MAX*0.5f*PI;
};
_mouseListener->onMouseUp = [&](Event *event) {
EventMouse* e = (EventMouse*)event;
switch(e->getMouseButton()) {
case MOUSE_BUTTON_LEFT:
break;
case MOUSE_BUTTON_RIGHT:
_isFPS = false;
break;
default:
break;
}
};
_mouseListener->onMouseDown = [&](Event *event) {
EventMouse* e = (EventMouse*)event;
switch(e->getMouseButton()) {
case MOUSE_BUTTON_LEFT:
break;
case MOUSE_BUTTON_RIGHT:
{
_isFPS = true;
_fpsAnchor = e->getLocation();
auto ro = _camera->getRotation3D();
CCLOG("%f,%f,%f", ro.x, ro.y, ro.z);
break;
}
default:
break;
}
};
_mouseListener->onMouseScroll = [&](Event *event) {
EventMouse* e = (EventMouse*)event;
CCLOG("%f, %f", e->getScrollX(), e->getScrollY());
float diff = e->getScrollY();
Vec3 dir = _camera->getRotationQuat() * Vec3{0.f, 0.f, -1.f};
dir.normalize();
_camera->setPosition3D(_camera->getPosition3D() + SCALL_MOVE_SCALE * -diff * dir);
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(_mouseListener, this);
scheduleUpdate();
return true;
}
示例7: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
auto director = Director::getInstance();
auto glview = CCQGLView::getInstance();
//glview->setBgColor(Color4B(50, 50, 50, 255));
director->setOpenGLView(glview);
_mainWindow.setGLView(glview->getGLWidget());
_mainWindow.initActionListWidget();
_mainWindow.show();
// turn on display FPS
director->setDisplayStats(false);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
auto scene = Scene::create();
scene->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
scene->setContentSize(Director::getInstance()->getVisibleSize());
//scene->setPosition(Director::getInstance()->getVisibleSize() / 2);
QString path;
QDir dir;
path = dir.currentPath();
FileUtils::getInstance()->addSearchPath(path.toStdString() + "/Resources");
FileUtils::getInstance()->addSearchPath("D://Resources");
auto keyboardEvent = EventListenerKeyboard::create();
keyboardEvent->onKeyPressed = [=](EventKeyboard::KeyCode code, Event*event)
{
if (code == EventKeyboard::KeyCode::KEY_CTRL)
{
m_dragMode = true;
}
};
keyboardEvent->onKeyReleased = [=](EventKeyboard::KeyCode code, Event*event)
{
if (code == EventKeyboard::KeyCode::KEY_CTRL)
{
m_dragMode = false;
}
};
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(keyboardEvent, -1);
auto scrollEvent = EventListenerMouse::create();
scrollEvent->onMouseScroll = [=](Event* event)
{
EventMouse* e = (EventMouse*)event;
int scrollX = e->getScrollX();
int scrollY = e->getScrollY();
scene->setScale(scene->getScale() + (float)scrollY / 100.0f);
Size currentSize = scene->getContentSize() * scene->getScale();
// scene->setScale();
};
auto eventListener = EventListenerTouchOneByOne::create();
eventListener->onTouchBegan = [=](Touch*touch, Event*event)->bool{
if (!m_dragMode)
return false;
return true;
};
eventListener->onTouchMoved = [=](Touch*touch, Event*event)
{
scene->setPosition(scene->getPosition() + touch->getDelta());
};
eventListener->setSwallowTouches(true);
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(eventListener, -3);
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(scrollEvent, -2);
// run
director->runWithScene(scene);
CCRect rect(0, 0, scene->getContentSize().width, scene->getContentSize().height);
CCSprite* grid = CCSprite::create("grid1_16x16_new_aaa.png");
grid->setTextureRect(rect);
Texture2D::TexParams params = {
GL_LINEAR,
GL_LINEAR,
GL_REPEAT,
GL_REPEAT
};
grid->getTexture()->setTexParameters(¶ms);
grid->setAnchorPoint(Vec2::ZERO);
grid->setPosition(Vec2::ZERO);
//.........这里部分代码省略.........
示例8: onMouseScroll
void Tower::onMouseScroll(cocos2d::Event* _event)
{
if(_isClosing == true || _returnFromSave == true)
return;// if we are pressing the close button, we dont want to build things!
EventMouse* e = (EventMouse*)_event;
_towerLayer->runAction(MoveBy::create(1/SCROLL_SPEED ,Vec2((-1*e->getScrollX())*SCROLL_MULTIPLIER, e->getScrollY()*SCROLL_MULTIPLIER)));
}