Skip to content

Commit

Permalink
add define to remove health fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Geokureli committed Mar 11, 2024
1 parent 1111e9c commit 125b1f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions flixel/FlxObject.hx
Original file line number Diff line number Diff line change
Expand Up @@ -699,11 +699,13 @@ class FlxObject extends FlxBasic
*/
public var maxAngular:Float = 10000;

#if FLX_HEALTH
/**
* Handy for storing health percentage or armor points or whatever.
*/
@:deprecated("This is no longer needed, as you can extend FlxObject")
@:deprecated("object.health is being removed in version 6.0.0")
public var health:Float = 1;
#end

/**
* Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts. Use bitwise operators to check the values
Expand Down Expand Up @@ -1200,19 +1202,21 @@ class FlxObject extends FlxBasic
return touching.hasAny(direction) && !wasTouching.hasAny(direction);
}

#if FLX_HEALTH
/**
* Reduces the `health` variable of this object by the amount specified in `Damage`.
* Calls `kill()` if health drops to or below zero.
*
* @param Damage How much health to take away (use a negative number to give a health bonus).
*/
@:deprecated("This is no longer needed, as you can extend FlxObject")
@:deprecated("object.health is being removed in version 6.0.0")
public function hurt(damage:Float):Void
{
health = health - damage;
if (health <= 0)
kill();
}
#end

/**
* Centers this `FlxObject` on the screen, either by the x axis, y axis, or both.
Expand Down
4 changes: 4 additions & 0 deletions flixel/system/macros/FlxDefines.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ private enum UserDefines
FLX_NO_SOUND_TRAY;
FLX_NO_FOCUS_LOST_SCREEN;
FLX_NO_DEBUG;
/* Removes FlxObject.health */
FLX_NO_HEALTH;
FLX_RECORD;
/* Defined in HaxeFlixel CI tests, do not use */
FLX_UNIT_TEST;
Expand Down Expand Up @@ -77,6 +79,7 @@ private enum HelperDefines
/* Used in HaxeFlixel CI, should have no effect on personal projects */
FLX_NO_CI;
FLX_SAVE;
FLX_HEALTH;
}

class FlxDefines
Expand Down Expand Up @@ -169,6 +172,7 @@ class FlxDefines
defineInversion(FLX_UNIT_TEST, FLX_NO_UNIT_TEST);
defineInversion(FLX_COVERAGE_TEST, FLX_NO_COVERAGE_TEST);
defineInversion(FLX_SWF_VERSION_TEST, FLX_NO_SWF_VERSION_TEST);
defineInversion(FLX_NO_HEALTH, FLX_HEALTH);
}

static function defineHelperDefines()
Expand Down

0 comments on commit 125b1f3

Please sign in to comment.