本文整理汇总了C++中UGameViewportClient::GetMousePosition方法的典型用法代码示例。如果您正苦于以下问题:C++ UGameViewportClient::GetMousePosition方法的具体用法?C++ UGameViewportClient::GetMousePosition怎么用?C++ UGameViewportClient::GetMousePosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UGameViewportClient
的用法示例。
在下文中一共展示了UGameViewportClient::GetMousePosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Tick
void AECommanderPawn::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
// Get the game viewport and make sure it exists as there is no
// guarantee that it does.
UGameViewportClient* GameViewport = GEngine->GameViewport;
if (!GameViewport)
{
return;
}
// Get the position of the mouse on the screen.
FVector2D MousePosition;
GameViewport->GetMousePosition(MousePosition);
// Get the size of the screen.
FVector2D ViewportSize;
GameViewport->GetViewportSize(ViewportSize);
// Make sure the game view port has focus (contains the mouse).
if (!GameViewport->IsFocused(GameViewport->Viewport))
{
return;
}
// Check if the mouse is at the left or right side of the
// screen and move accordingly.
if (MousePosition.X < CameraScrollBoundary)
{
}
else if ((ViewportSize.X - MousePosition.X) < CameraScrollBoundary)
{
}
// Check if the mouse is at the top or bottom of the screen
// and move accordingly.
if (MousePosition.Y < CameraScrollBoundary)
{
}
else if ((ViewportSize.Y - MousePosition.Y) < CameraScrollBoundary)
{
}
}
示例2: Tick
void AMainCameraSpecPawn::Tick(float DeltaSeconds) {
Super::Tick(DeltaSeconds);
FVector2D MousePosition;
FVector2D ViewportSize;
UGameViewportClient* GameViewport = GEngine->GameViewport;
check(GameViewport);
GameViewport->GetViewportSize(ViewportSize);
// Check if input is detectable
if (GameViewport->IsFocused(GameViewport->Viewport) &&
GameViewport->GetMousePosition(MousePosition) &&
bCanMoveCamera) {
// Edge of screen movement
if (MousePosition.X < CameraScrollBounds) {
YMovement = -1.0f;
} else if (ViewportSize.X - MousePosition.X < CameraScrollBounds) {
YMovement = 1.0f;
}
if (MousePosition.Y < CameraScrollBounds) {
XMovement = 1.0f;
}
else if (ViewportSize.Y - MousePosition.Y < CameraScrollBounds) {
XMovement = -1.0f;
}
// movement
MoveCameraForward(XMovement * FastMoveMultiplier * DeltaSeconds);
MoveCameraRight(YMovement * FastMoveMultiplier * DeltaSeconds);
}
}