本文整理汇总了C++中InputState::mouseX方法的典型用法代码示例。如果您正苦于以下问题:C++ InputState::mouseX方法的具体用法?C++ InputState::mouseX怎么用?C++ InputState::mouseX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputState
的用法示例。
在下文中一共展示了InputState::mouseX方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool CameraTool2D::doStartMouseDrag(const InputState& inputState) {
if (pan(inputState)) {
m_lastMousePos = Vec2f(static_cast<float>(inputState.mouseX()),
static_cast<float>(inputState.mouseY()));
return true;
}
return false;
}
示例2: currentMousePos
bool CameraTool2D::doMouseDrag(const InputState& inputState) {
if (pan(inputState)) {
const Vec2f currentMousePos(static_cast<float>(inputState.mouseX()), static_cast<float>(inputState.mouseY()));
const Vec3f lastWorldPos = m_camera.unproject(m_lastMousePos.x(), m_lastMousePos.y(), 0.0f);
const Vec3f currentWorldPos = m_camera.unproject(currentMousePos.x(), currentMousePos.y(), 0.0f);
const Vec3f delta = currentWorldPos - lastWorldPos;
m_camera.moveBy(-delta);
m_lastMousePos = currentMousePos;
return true;
}
return false;
}
示例3: pref
void CameraTool2D::doMouseScroll(const InputState& inputState) {
if (zoom(inputState)) {
const float speed = pref(Preferences::CameraMouseWheelInvert) ? -1.0f : 1.0f;
if (inputState.scrollY() != 0.0f) {
const Vec2f mousePos(static_cast<float>(inputState.mouseX()), static_cast<float>(inputState.mouseY()));
const Vec3f oldWorldPos = m_camera.unproject(mousePos.x(), mousePos.y(), 0.0f);
const float factor = 1.0f + inputState.scrollY() / 50.0f * speed;
m_camera.zoom(factor);
const Vec3f newWorldPos = m_camera.unproject(mousePos.x(), mousePos.y(), 0.0f);
const Vec3f delta = newWorldPos - oldWorldPos;
m_camera.moveBy(-delta);
}
}
}