Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlxObject: fix overlapsPoint() if overlap is at x or y = 0 #1818

Merged
merged 3 commits into from
Apr 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flixel/FlxObject.hx
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ class FlxObject extends FlxBasic
{
if (!InScreenSpace)
{
return (point.x > x) && (point.x < x + width) && (point.y > y) && (point.y < y + height);
return (point.x >= x) && (point.x < x + width) && (point.y >= y) && (point.y < y + height);
}

if (Camera == null)
Expand All @@ -792,7 +792,7 @@ class FlxObject extends FlxBasic
var yPos:Float = point.y - Camera.scroll.y;
getScreenPosition(_point, Camera);
point.putWeak();
return (xPos > _point.x) && (xPos < _point.x + width) && (yPos > _point.y) && (yPos < _point.y + height);
return (xPos >= _point.x) && (xPos < _point.x + width) && (yPos >= _point.y) && (yPos < _point.y + height);
}

/**
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/src/flixel/ui/FlxButtonTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,23 @@ class FlxButtonTest extends FlxTest
{
setAndAssertText(null);
}

@Test // #1818
function testHighlightStatusInUpperLeftCorner()
{
FlxG.state.add(button);

button.setPosition();
step(1);
Assert.areEqual(FlxButton.HIGHLIGHT, button.status);

FlxG.state.remove(button);
}

@Test // #1365
function testTriggerAnimationOnce()
{
button.x = 1; // put it slightly to the right of the cursor so that it isn't highlighted by default
button.animation.add("normal", [for (i in 0...4) 0], 30, false);
FlxG.state.add(button);
step(2);
Expand All @@ -80,6 +93,7 @@ class FlxButtonTest extends FlxTest
step(10);
Assert.areEqual("normal", button.animation.curAnim.name);
Assert.areEqual(true, button.animation.finished);
FlxG.state.remove(button);
}

function setAndAssertText(text:String)
Expand Down