Skip to content

Commit

Permalink
Revert "add doc"
Browse files Browse the repository at this point in the history
This reverts commit 7848e9e.
  • Loading branch information
Geokureli committed Aug 25, 2023
1 parent 7848e9e commit 1709031
Showing 1 changed file with 11 additions and 29 deletions.
40 changes: 11 additions & 29 deletions flixel/FlxCamera.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1164,30 +1164,15 @@ class FlxCamera extends FlxBasic
* Called every frame by camera's `update()` method.
*/
public function updateScroll():Void
{
// Make sure we didn't go outside the camera's bounds
bindScrollPos(scroll);
}

/**
* Takes the desired scroll position and restricts it to the camera's min/max scroll properties.
* This modifies the given point.
*
* @param scrollPos The scroll position
* @return The same point passed in, moved within the scroll bounds
* @since 5.4.0
*/
public function bindScrollPos(scrollPos:FlxPoint)
{
var minX:Null<Float> = minScrollX == null ? null : minScrollX - (zoom - 1) * width / (2 * zoom);
var maxX:Null<Float> = maxScrollX == null ? null : maxScrollX + (zoom - 1) * width / (2 * zoom);
var minY:Null<Float> = minScrollY == null ? null : minScrollY - (zoom - 1) * height / (2 * zoom);
var maxY:Null<Float> = maxScrollY == null ? null : maxScrollY + (zoom - 1) * height / (2 * zoom);

// keep point with bounds
scrollPos.x = FlxMath.bound(scrollPos.x, minX, (maxX != null) ? maxX - width : null);
scrollPos.y = FlxMath.bound(scrollPos.y, minY, (maxY != null) ? maxY - height : null);
return scrollPos;
// Make sure we didn't go outside the camera's bounds
scroll.x = FlxMath.bound(scroll.x, minX, (maxX != null) ? maxX - width : null);
scroll.y = FlxMath.bound(scroll.y, minY, (maxY != null) ? maxY - height : null);
}

/**
Expand All @@ -1212,26 +1197,23 @@ class FlxCamera extends FlxBasic

if (style == SCREEN_BY_SCREEN)
{
if (targetX >= viewRight)
if (targetX >= (scroll.x + width))
{
_scrollTarget.x += viewWidth;
_scrollTarget.x += width;
}
else if (targetX + target.width < viewLeft)
else if (targetX < scroll.x)
{
_scrollTarget.x -= viewWidth;
_scrollTarget.x -= width;
}

if (targetY >= viewBottom)
if (targetY >= (scroll.y + height))
{
_scrollTarget.y += viewHeight;
_scrollTarget.y += height;
}
else if (targetY + target.height < viewTop)
else if (targetY < scroll.y)
{
_scrollTarget.y -= viewHeight;
_scrollTarget.y -= height;
}

// without this we see weird behavior when switching to SCREEN_BY_SCREEN at arbitrary scroll positions
bindScrollPos(_scrollTarget);
}
else
{
Expand Down

0 comments on commit 1709031

Please sign in to comment.