Skip to content

Commit

Permalink
remove implicit casts of int to/from directions (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
Geokureli authored Dec 9, 2024
1 parent 0d07752 commit 4d9dc50
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
16 changes: 8 additions & 8 deletions flixel/addons/display/FlxExtendedMouseSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,11 @@ class FlxExtendedMouseSprite extends FlxSprite
if (acceleration.x < 0)
{
// Gravity is pulling them left
if ((touching & WALL) != 0)
if (touching.has(WALL))
{
drag.y = frictionY;

if ((wasTouching & WALL) == 0)
if (!wasTouching.has(WALL))
{
if (velocity.x < toleranceX)
{
Expand All @@ -475,12 +475,12 @@ class FlxExtendedMouseSprite extends FlxSprite
else if (acceleration.x > 0)
{
// Gravity is pulling them right
if ((touching & WALL) != 0)
if (touching.has(WALL))
{
// Stop them sliding like on ice
drag.y = frictionY;

if ((wasTouching & WALL) == 0)
if (!wasTouching.has(WALL))
{
if (velocity.x > -toleranceX)
{
Expand All @@ -501,11 +501,11 @@ class FlxExtendedMouseSprite extends FlxSprite
if (acceleration.y < 0)
{
// Gravity is pulling them up (velocity is negative)
if ((touching & CEILING) != 0)
if (touching.has(CEILING))
{
drag.x = frictionX;

if ((wasTouching & CEILING) == 0)
if (!wasTouching.has(CEILING))
{
if (velocity.y < toleranceY)
{
Expand All @@ -521,12 +521,12 @@ class FlxExtendedMouseSprite extends FlxSprite
else if (acceleration.y > 0)
{
// Gravity is pulling them down (velocity is positive)
if ((touching & FLOOR) != 0)
if (touching.has(FLOOR))
{
// Stop them sliding like on ice
drag.x = frictionX;

if ((wasTouching & FLOOR) == 0)
if (!wasTouching.has(FLOOR))
{
if (velocity.y > -toleranceY)
{
Expand Down
3 changes: 2 additions & 1 deletion flixel/addons/display/FlxNestedSprite.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package flixel.addons.display;

import flixel.util.FlxDirectionFlags;
import openfl.geom.ColorTransform;
import flixel.FlxBasic;
import flixel.FlxG;
Expand Down Expand Up @@ -401,7 +402,7 @@ class FlxNestedSprite extends FlxSprite
return color;
}

override function set_facing(Direction:Int):Int
override function set_facing(Direction:FlxDirectionFlags):FlxDirectionFlags
{
super.set_facing(Direction);
if (children != null)
Expand Down
8 changes: 4 additions & 4 deletions flixel/addons/effects/FlxClothSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,10 @@ class FlxClothSprite extends FlxSprite
y: r * heightInTiles,
oldx: c * widthInTiles,
oldy: r * heightInTiles,
pinned: ((r == 0 && pinnedSide & UP != 0)
|| (r == rows - 1 && pinnedSide & DOWN != 0)
|| (c == 0 && pinnedSide & LEFT != 0)
|| (c == columns - 1 && pinnedSide & RIGHT != 0))
pinned: ((r == 0 && pinnedSide.has(UP))
|| (r == rows - 1 && pinnedSide.has(DOWN))
|| (c == 0 && pinnedSide.has(LEFT))
|| (c == columns - 1 && pinnedSide.has(RIGHT)))
});

_vertices.push(c * widthInTiles);
Expand Down
6 changes: 4 additions & 2 deletions flixel/addons/plugin/control/FlxControlHandler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import flixel.sound.FlxSound;
#else
import flixel.system.FlxSound;
#end
import flixel.util.FlxDirectionFlags;

/**
*
Expand Down Expand Up @@ -173,7 +174,7 @@ class FlxControlHandler
// Internal time of when they last collided with a valid jumpSurface
var _extraSurfaceTime:Int;
// The surfaces they can jump from (i.e. FLOOR)
var _jumpSurface:Int;
var _jumpSurface:FlxDirectionFlags;
// A function to call every time they jump
var _jumpCallback:Void->Void;

Expand Down Expand Up @@ -612,7 +613,8 @@ class FlxControlHandler
* @param callback A user defined function to call when the Sprite jumps
* @param altKey Specify an alternative jump key that works AS WELL AS the primary jump key (TODO)
*/
public function setJumpButton(key:String, keymode:Int, height:Int, surface:Int, repeatDelay:Int = 250, jumpFromFall:Int = 0, ?callback:Void->Void,
public function setJumpButton(key:String, keymode:Int, height:Int, surface:FlxDirectionFlags, repeatDelay:Int = 250, jumpFromFall:Int = 0,
?callback:Void->Void,
altKey:String = ""):Void
{
_jumpKey = key;
Expand Down
3 changes: 2 additions & 1 deletion flixel/addons/util/FlxScene.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import flixel.tile.FlxTilemap;
import flixel.ui.FlxButton;
import flixel.util.FlxAxes;
import flixel.util.FlxColor;
import flixel.util.FlxDirectionFlags;
import haxe.xml.Parser;
import openfl.Assets;

Expand Down Expand Up @@ -250,7 +251,7 @@ class FlxScene

case "tile":
var id = Std.parseInt(element.att.id);
var collision = Std.parseInt(element.att.collision);
var collision:FlxDirectionFlags = cast Std.parseInt(element.att.collision);

tilemap.setTileProperties(id, collision);
}
Expand Down

0 comments on commit 4d9dc50

Please sign in to comment.