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

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

@:value({ axes : XY })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)

staticinlineclear<T>(array:Array<T>):Array<T>

Clears the content of an array

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.

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

Dynamic color.

Returns:

The result color, or null if invalid.

staticinlinegetDefault<T>(v:Null<T>, defaultValue:T):T

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

staticgetLastExceptionStack():String

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 ot 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.

staticinlineisNaN(v:Dynamic):Bool

Whenever a value is NaN or not.

Parameters:

v

Value

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

@:value({ fpsSensitive : false })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

@:value({ min : 0 })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 Final array

staticinlineopenURL(url:String):Void

Opens an URL in the browser.

Parameters:

null

url

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

@:value({ volume : 1, menuSFX : SCROLL })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

@:value({ fadeIn : false })staticplayMenuSong(fadeIn:Bool = false):Void

Plays the main menu theme.

Parameters:

null

fadeIn

@:value({ DefaultBPM : 102, Looped : true, Volume : 1, Persist : false })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

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

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

@:value({ maxScale : 0, fill : true })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)