本文整理汇总了C++中InputState::IsButtonDragEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ InputState::IsButtonDragEvent方法的具体用法?C++ InputState::IsButtonDragEvent怎么用?C++ InputState::IsButtonDragEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputState
的用法示例。
在下文中一共展示了InputState::IsButtonDragEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fabsf
void
WindowFrame::MouseMoved( int iWindow[2], InputState& iInput ) {
if ( iWindow[0] >= 0 && iWindow[0] <= mWidth-1 &&
iWindow[1] >= 0 && iWindow[1] <= mHeight-1 ) {
if ( iInput.IsButtonDragEvent() ) {
// Calculate the delta. Make sure there is one; if not, no mouse
// moved event.
float delta[2];
delta[0] = iWindow[0] - mLastMoved[0];
delta[1] = iWindow[1] - mLastMoved[1];
if ( delta[0] != 0 || delta[1] != 0 ) {
// Find the greater one (absolute value). Divide each delta by
// this value to get the step; one will be 1.0, and the other
// will be < 1.0.
float greater = fabsf(delta[0]) > fabsf(delta[1]) ?
fabsf(delta[0]) : fabsf(delta[1]);
delta[0] /= greater;
delta[1] /= greater;
// We step window coords in floats, but transform to ints. Start
// at the last moved place.
float windowF[2];
int windowI[2];
windowF[0] = mLastMoved[0];
windowF[1] = mLastMoved[1];
// While we're not at the current location... NOTE - this
// should work, but jc can't handle simple float comparison,
// so we have to do wacky 0 comparison instead.
while ( !( fabsf((float)iWindow[0] - windowF[0]) < 1.0 &&
fabsf((float)iWindow[1] - windowF[1]) < 1.0) ) {
// Get an integer value and send it to the frame.
windowI[0] = (int) rint( windowF[0] );
windowI[1] = (int) rint( windowF[1] );
this->DoMouseMoved( windowI, iInput );
// Increment the float window coords.
windowF[0] += delta[0];
windowF[1] += delta[1];
if ( windowF[0] < -10 || windowF[1] < -10 )
exit( 1 );
}
}
} else {
this->DoMouseMoved( iWindow, iInput );
}
// Save this position.
mLastMoved[0] = iWindow[0];
mLastMoved[1] = iWindow[1];
}
}