allow camera shaking to exit map borders
This commit is contained in:
@@ -35,24 +35,27 @@ namespace OpenRA.Graphics
|
||||
public static int TicksSinceLastMove = 0;
|
||||
public static int2 LastMousePos;
|
||||
|
||||
public void Scroll(float2 delta)
|
||||
public void Scroll(float2 delta){
|
||||
this.Scroll(delta, false);
|
||||
}
|
||||
|
||||
public void Scroll(float2 delta, bool ignoreBorders)
|
||||
{
|
||||
float2 newScrollPosition = scrollPosition + delta;
|
||||
|
||||
if(!ignoreBorders){
|
||||
float2 topLeftBorder = (Game.CellSize* mapStart).ToFloat2();
|
||||
float2 bottomRightBorder = (Game.CellSize* mapEnd).ToFloat2();
|
||||
float2 newScrollPosition = scrollPosition + delta;
|
||||
|
||||
if(newScrollPosition.Y < topLeftBorder.Y)
|
||||
newScrollPosition.Y = topLeftBorder.Y;
|
||||
|
||||
if(newScrollPosition.X < topLeftBorder.X)
|
||||
newScrollPosition.X = topLeftBorder.X;
|
||||
|
||||
if(newScrollPosition.Y > bottomRightBorder.Y-screenSize.Y)
|
||||
newScrollPosition.Y = bottomRightBorder.Y-screenSize.Y;
|
||||
|
||||
if(newScrollPosition.X > bottomRightBorder.X-screenSize.X)
|
||||
newScrollPosition.X = bottomRightBorder.X-screenSize.X;
|
||||
|
||||
}
|
||||
scrollPosition = newScrollPosition;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public void Tick (Actor self)
|
||||
{
|
||||
Game.viewport.Scroll(GetScrollOffset());
|
||||
Game.viewport.Scroll(GetScrollOffset(), true);
|
||||
shakeEffects.RemoveAll(t => t.ExpiryTime == ticks);
|
||||
ticks++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user