Skip to content

Instantly share code, notes, and snippets.

@glcoder
Created April 21, 2012 16:06
Show Gist options
  • Save glcoder/2438024 to your computer and use it in GitHub Desktop.
Save glcoder/2438024 to your computer and use it in GitHub Desktop.
Utility sign function for Flixel
diff -Bbwur AdamAtomic-flixel-8989e50/org/flixel/FlxU.as AdamAtomic-flixel-8989e50-new/org/flixel/FlxU.as
--- AdamAtomic-flixel-8989e50/org/flixel/FlxU.as 2011-08-22 09:03:52 +0400
+++ AdamAtomic-flixel-8989e50-new/org/flixel/FlxU.as 2012-04-21 20:04:29 +0400
@@ -20,6 +20,18 @@
}
/**
+ * Extract the sign of a number.
+ *
+ * @param Value Any number.
+ *
+ * @return In case Value < 0 returns -1, otherwise returns 1
+ */
+ static public function sign(Value:Number):Number
+ {
+ return (Value<0)?-1:1;
+ }
+
+ /**
* Calculate the absolute value of a number.
*
* @param Value Any number.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment