Skip to content

Commit 8897a56

Browse files
authored
add define to remove health fields (HaxeFlixel#3067)
* add define to remove health fields * add define to coverage
1 parent 9ea597a commit 8897a56

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

flixel/FlxObject.hx

+6-2
Original file line numberDiff line numberDiff line change
@@ -699,11 +699,13 @@ class FlxObject extends FlxBasic
699699
*/
700700
public var maxAngular:Float = 10000;
701701

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

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

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

12171221
/**
12181222
* Centers this `FlxObject` on the screen, either by the x axis, y axis, or both.

flixel/system/macros/FlxDefines.hx

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ private enum UserDefines
2222
FLX_NO_SOUND_TRAY;
2323
FLX_NO_FOCUS_LOST_SCREEN;
2424
FLX_NO_DEBUG;
25+
/* Removes FlxObject.health */
26+
FLX_NO_HEALTH;
2527
FLX_RECORD;
2628
/* Defined in HaxeFlixel CI tests, do not use */
2729
FLX_UNIT_TEST;
@@ -77,6 +79,7 @@ private enum HelperDefines
7779
/* Used in HaxeFlixel CI, should have no effect on personal projects */
7880
FLX_NO_CI;
7981
FLX_SAVE;
82+
FLX_HEALTH;
8083
}
8184

8285
class FlxDefines
@@ -169,6 +172,7 @@ class FlxDefines
169172
defineInversion(FLX_UNIT_TEST, FLX_NO_UNIT_TEST);
170173
defineInversion(FLX_COVERAGE_TEST, FLX_NO_COVERAGE_TEST);
171174
defineInversion(FLX_SWF_VERSION_TEST, FLX_NO_SWF_VERSION_TEST);
175+
defineInversion(FLX_NO_HEALTH, FLX_HEALTH);
172176
}
173177

174178
static function defineHelperDefines()

tests/coverage/Project.xml

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<haxedef name="FLX_RECORD" />
5050
<haxedef name="FLX_RENDER_TRIANGLE" />
5151
<haxedef name="FLX_NO_SAVE" />
52+
<haxedef name="FLX_NO_HEALTH" />
5253
</section>
5354
<section if="coverage2">
5455
<haxedef name="debug" />

0 commit comments

Comments
 (0)