Static methods
staticinlineaddEndZeros(str:String, num:Int):String
Add several zeros at the end of a string, so that 2
becomes 20
, useful for ms.
Parameters:
str | String to add zeros |
---|---|
num | The length required |
staticaddMissingFolders(path:String):String
Creates eventual missing folders to the specified path
WARNING: eventual files in path
will be considered as folders! Just to make possible folders be named as songs.json
for example
Parameters:
path | Path to check. |
---|
Returns:
The initial Path.
staticinlineaddZeros(str:String, num:Int):String
Add several zeros at the beginning of a string, so that 2
becomes 02
.
Parameters:
str | String to add zeros |
---|---|
num | The length required |
staticautoSetFormat(text:FlxText, formats:Array<TextFormat>):FlxText
Sets automatically all the compatible formats to a text.
WARNING: These are dependant from the font, so if the font doesn't support for example the bold
format it won't work!
Parameters:
text | Text to set the format for |
---|---|
formats | Array of the formats (to get the formats from a node, you can use |
staticinlinecameraCenter(obj:FlxObject, cam:FlxCamera, axes:FlxAxes = XY):Void
Centers an object in a camera's field, basically screenCenter()
but camera.width
and camera.height
are used instead of FlxG.width
and FlxG.height
.
Parameters:
obj | Sprite to center |
---|---|
cam | Camera |
axes | Axes (XY) |
staticcoolTextFile(path:String):Array<String>
Allows you to split a text file from a path, into a "cool text file", AKA a list. Allows for comments. For example,
# comment
test1
test2
will return ["test1", "test2"]
Parameters:
path |
---|
Returns:
Array
staticinlinecopyColorTransform(color1:ColorTransform, color2:ColorTransform):Void
Copies a color transform from color1 to color2
Parameters:
color1 | Color transform to copy to |
---|---|
color2 | Color transform to copy from |
staticdeleteFolder(delete:String):Void
Deletes a folder recursively
Parameters:
delete | Path to the folder. |
---|
staticinlinefloorInt(e:Float):Int
Equivalent of Math.floor
, except doesn't require a Int -> Float -> Int conversion.
Parameters:
e | Value to get the floor of. |
---|
staticformatNumberRange(numbers:Array<Int>, seperator:String = ","):String
Converts an array of numbers into a string of ranges. Example: [1,2,3,5,7,8,9,8,7,6,5] -> "1..3,5,7..9,8..5"
Parameters:
numbers | Array of numbers |
---|
Returns:
String representing the ranges
staticinlinefpsLerp(v1:Float, v2:Float, ratio:Float):Float
Alternative linear interpolation function for each frame use, without worrying about framerate changes.
Parameters:
v1 | Begin value |
---|---|
v2 | End value |
ratio | Ratio |
Returns:
Float Final value
staticinlinegetAtt(xml:Access, name:String):String
Gets an XML attribute from an Access
abstract, without throwing an exception if invalid.
Example: xml.getAtt("test").getDefault("Hello, World!");
Parameters:
xml | XML to get the attribute from |
---|---|
name | Name of the attribute |
staticgetColorFromDynamic(c:Dynamic):Null<FlxColor>
Tries to get a color from a Dynamic
variable.
Parameters:
c |
|
---|
Returns:
The result color, or null
if invalid.
staticinlinegetFPSRatio(ratio:Float):Float
Modifies a lerp ratio based on current FPS to keep a stable speed on higher framerate.
Parameters:
ratio | Ratio |
---|
Returns:
FPS-Modified Ratio
staticinlinegetMacroAbstractClass(className:String):Class<Dynamic>
Gets the macro class created by hscript-improved for an abstract / enum
staticgetSizeString(size:Float):String
Returns a string representation of a size, following this format: 1.02 GB
, 134.00 MB
Parameters:
size | Size to convert to string |
---|
Returns:
String Result string representation
staticinlineindexOfFromLast<T>(array:Array<T>, element:T):Int
Basically indexOf, but starts from the end.
Parameters:
array | Array to scan |
---|---|
element | Element |
Returns:
Index, or -1 if unsuccessful.
staticinlinekeyToString(key:Null<FlxKey>):String
Returns a simple string representation of a FlxKey. Used in Controls options.
Parameters:
key | Key |
---|
Returns:
Simple representation
staticinlinelast<T>(array:Array<T>):T
Returns the last of an Array
Parameters:
array | Array |
---|
Returns:
T Last element
staticinlinelerpColor(color1:FlxColor, color2:FlxColor, ratio:Float, fpsSensitive:Bool = false):FlxColor
Lerps from color1 into color2 (Shortcut to FlxColor.interpolate
)
Parameters:
color1 | Color 1 |
---|---|
color2 | Color 2 |
ratio | Ratio |
fpsSensitive | Whenever the ratio should be fps sensitive (adapted when game is running at 120 instead of 60) |
staticloadAnimatedGraphic(spr:FlxSprite, path:String):FlxSprite
Loads an animated graphic, and automatically animates it.
Parameters:
spr | Sprite to load the graphic for |
---|---|
path | Path to the graphic |
staticinlinemaxInt(p1:Int, p2:Int):Int
Equivalent of Math.max
, except doesn't require a Int -> Float -> Int conversion.
Parameters:
p1 | |
---|---|
p2 |
Returns:
return p1 < p2 ? p2 : p1
staticinlinenumberArray(max:Int, min:Int = 0):Array<Int>
Returns an array of number from min to max. Equivalent of [for (i in min...max) i]
.
Parameters:
max | Max value |
---|---|
min | Minimal value (0) |
Returns:
Array
staticparseJson(assetPath:String):Unknown
Shortcut to parse JSON from an Asset path
Parameters:
assetPath | Path to the JSON asset. |
---|
staticinlineparseJsonString(str:String):Unknown
Shortcut to parse a JSON string
Parameters:
str | Path to the JSON string |
---|
Returns:
Parsed JSON
staticparseNumberRange(input:String):Array<Int>
Converts a string of "1..3,5,7..9,8..5" into an array of numbers like [1,2,3,5,7,8,9,8,7,6,5]
Parameters:
input | String to parse |
---|
Returns:
Array of numbers
staticinlineplayMenuSFX(menuSFX:CoolSfx = SCROLL, volume:Float = 1):Void
Plays a specified Menu SFX.
Parameters:
menuSFX | Menu SFX to play |
---|---|
volume | At which volume it should play |
staticplayMenuSong(fadeIn:Bool = false):Void
Plays the main menu theme.
Parameters:
null | fadeIn |
---|
staticplayMusic(path:String, Persist:Bool = false, Volume:Int = 1, Looped:Bool = true, DefaultBPM:Int = 102, ?Group:FlxSoundGroup):Void
Plays music, while resetting the Conductor, and taking info from INI in count.
Parameters:
path | Path to the music |
---|---|
Persist | Whenever the music should persist while switching states |
DefaultBPM | Default BPM of the music (102) |
Volume | Volume of the music (1) |
Looped | Whenever the music loops (true) |
Group | A group that this music belongs to (default) |
staticpreloadCharacter(name:String, ?spriteName:String):Void
Preloads a character.
Parameters:
name | Character name |
---|---|
spriteName | (Optional) sprite name. |
staticinlinepushGroup<T>(array:Array<T>, args:Rest<T>):Array<T>
Push an entire group into an array.
Parameters:
array | Array to push the group into |
---|---|
...args | Group entries |
Returns:
Array
staticinlineremoveIP(msg:String):String
Replaces in a string any kind of IP with [Your IP]
making the string safer to trace.
Parameters:
msg | String to check and edit |
---|
Returns:
String Result without any kind of IP
staticinlinereplay(sound:FlxSound):Void
Stops a sound, set its time to 0 then play it again.
Parameters:
sound | Sound to replay. |
---|
staticresetSprite(spr:FlxSprite, x:Float, y:Float):Void
Resets an FlxSprite
Parameters:
spr | Sprite to reset |
---|---|
x | New X position |
y | New Y position |
staticinlinesafeAddAttributes(path:String, attrib:OneOfTwo<FileAttribute, Int>, useAbsol:Bool = true):Int
Adds one (or more) file attributes to a file or a folder adding eventual missing folders in the path
(WARNING: Only works on windows
for now. On other platforms the return code it's always going to be 0
but still creates eventual missing folders if the platforms allows it to).
Parameters:
path | Path to the file or folder |
---|---|
attrib | The attribute(s) to add (WARNING: There are some non settable attributes, such as the |
useAbsol | If it should use the absolute path (By default it's |
Returns:
The result code: 0
means that it failed setting
staticinlinesafeGetAttributes(path:String, useAbsol:Bool = true):FileAttributeWrapper
Gets file attributes from a file or a folder adding eventual missing folders in the path
(WARNING: Only works on windows
for now. On other platforms the attributes' value it's always going to be 0
-thanks to the wrapper you can also use isNothing
for checking- but still creates eventual missing folders if the platforms allows it to).
Parameters:
path | Path to the file or folder |
---|---|
useAbsol | If it should use the absolute path (By default it's |
Returns:
The attributes through the FileAttributeWrapper
staticinlinesafeRemoveAttributes(path:String, attrib:OneOfTwo<FileAttribute, Int>, useAbsol:Bool = true):Int
Removes one (or more) file attributes to a file or a folder adding eventual missing folders in the path
(WARNING: Only works on windows
for now. On other platforms the return code it's always going to be 0
but still creates eventual missing folders if the platforms allows it to).
Parameters:
path | Path to the file or folder |
---|---|
attrib | The attribute(s) to remove (WARNING: There are some non settable attributes, such as the |
useAbsol | If it should use the absolute path (By default it's |
Returns:
The result code: 0
means that it failed setting
staticsafeSaveFile(path:String, content:OneOfTwo<String, Bytes>, showErrorBox:Bool = true):Void
Safe saves a file (even adding eventual missing folders) and shows a warning box instead of making the program crash
Parameters:
path | Path to save the file at. |
---|---|
content | Content of the file to save (as String or Bytes). |
staticinlinesafeSetAttributes(path:String, attrib:OneOfThree<FileAttribute, FileAttributeWrapper, Int>, useAbsol:Bool = true):Int
Sets file attributes to a file or a folder adding eventual missing folders in the path
(WARNING: Only works on windows
for now. On other platforms the return code it's always going to be 0
but still creates eventual missing folders if the platforms allows it to).
Parameters:
path | Path to the file or folder |
---|---|
attrib | The attribute(s) to set (WARNING: There are some non settable attributes, such as the |
useAbsol | If it should use the absolute path (By default it's |
Returns:
The result code: 0
means that it failed setting
staticsetFieldDefault<T>(v:Dynamic, name:String, defaultValue:T):T
Sets a field's default value, and returns it. In case it already exists, returns the existing one.
Parameters:
v | Dynamic to set the default value to |
---|---|
name | Name of the value |
defaultValue | Default value |
Returns:
T New/old value.
staticinlinesetMusic(frontEnd:SoundFrontEnd, music:FlxSound):Void
Sets a SoundFrontEnd's music to a FlxSound.
Example: FlxG.sound.setMusic(music);
Parameters:
frontEnd | SoundFrontEnd to set the music of |
---|---|
music | Music |
staticinlinesetSpriteSize(sprite:FlxSprite, width:Float, height:Float):Void
Equivalent of setGraphicSize
, except that it can accept floats and automatically updates the hitbox.
Parameters:
sprite | Sprite to set the size of |
---|---|
width | Width |
height | Height |
staticinlinesetUnstretchedGraphicSize(sprite:FlxSprite, width:Int, height:Int, fill:Bool = true, maxScale:Float = 0):Void
Allows you to set a graphic size (ex: 150x150), with proper hitbox without a stretched sprite.
Parameters:
sprite | Sprite to apply the new graphic size to |
---|---|
width | Width |
height | Height |
fill | Whenever the sprite should fill instead of shrinking (true) |
maxScale | Maximum scale (0 / none) |
staticswitchAnimFrames(anim1:FlxAnimation, anim2:FlxAnimation):Void
Switches frames from 2 FlxAnimations.
Parameters:
anim1 | First animation |
---|---|
anim2 | Second animation |
staticinlinetimeToStr(time:Float):String
Converts a timestamp to a readable format such as 01:22
(mm:ss
)