moving element, or whole seperate widget I layer over the widget containing the unmoving stuff and then move around the whole widget? delete and remake whole seperate widget every frame with gradualy changing position to simulate movement?
SPanel, or SCompoundWidget? irrelevant?
controlling the padding on some slate widget elements seems to work. in my case it works for SBoxs, a descendant of SCompound widgets:
GEngine->GameViewport->GetViewportSize(viewportSize);
int32 X = FGenericPlatformMath::FloorToInt(viewportSize.X);
int32 Y = FGenericPlatformMath::FloorToInt(viewportSize.Y);
DPIScale = GetDefault<UUserInterfaceSettings>(UUserInterfaceSettings::StaticClass())->GetDPIScaleBasedOnSize(FIntPoint(X, Y));
adjustedViewportSize = (1 / DPIScale) * viewportSize;
activeMarbles.Add(SNew(SBox));
activeMarbles[activeMarbles.Num() - 1]->SetPadding(CalculateTilePosition(startingPos, adjustedViewportSize));
const FMargin CalculateTilePosition(FVector2D tileCoords, FVector2D adjustedViewportSize)//this has been adjusted to respond to 1D arr coordinates
{//this will only work if screenSize.X >= screenSize.Y
float viewportX = adjustedViewportSize.X;
float viewportY = adjustedViewportSize.Y;
float fOne = (viewportX - viewportY) / 2;
float leftPad = fOne + (viewportY / 15) * tileCoords.X;
float topPad = (viewportY / 15) * tileCoords.Y;
float rightPad = fOne + (viewportY / 15) * (15 - (tileCoords.X + 1));
float bottomPad = viewportY - (viewportY / 15) * (tileCoords.Y + 1);
return FMargin(leftPad, topPad, rightPad, bottomPad);
}
my code works in regards to a hypothetical square 15 by 15 tile grid I envision in the center of the screen the full height of the Y axis of the screen. To simulate movement I simply set a SBox elements padding on tick to the results of CalculateTilePosition altering the tileCoords argument accordingly every tick
questions?
1 Like
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.