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

add hasAny and correct isTouching #2705

Merged
merged 1 commit into from
Dec 22, 2022
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 @@ -1177,7 +1177,7 @@ class FlxObject extends FlxBasic
*/
public inline function isTouching(direction:FlxDirectionFlags):Bool
{
return touching.has(direction);
return touching.hasAny(direction);
}

/**
Expand All @@ -1189,7 +1189,7 @@ class FlxObject extends FlxBasic
*/
public inline function justTouched(direction:FlxDirectionFlags):Bool
{
return touching.has(direction) && !wasTouching.has(direction);
return touching.hasAny(direction) && !wasTouching.hasAny(direction);
}

/**
Expand Down
10 changes: 9 additions & 1 deletion flixel/util/FlxDirectionFlags.hx
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,21 @@ import flixel.math.FlxAngle;
}

/**
* Returns true if this contains all of the supplied flags.
* Returns true if this contains **all** of the supplied flags.
*/
public inline function has(dir:FlxDirectionFlags):Bool
{
return this & dir == dir;
}

/**
* Returns true if this contains **any** of the supplied flags.
*/
public inline function hasAny(dir:FlxDirectionFlags):Bool
{
return this & dir > 0;
}

/**
* Creates a new `FlxDirections` that includes the supplied directions.
*/
Expand Down