class ScriptedFlxObject
package funkin.modding.base
extends FlxObject › FlxBasic
implements HScriptedClass
Available on all platforms
A script that can be tied to an FlxObject. Create a scripted class that extends FlxObject to use this.
Static methods
staticinit(clsName:String, ?x:Float, ?y:Float, ?width:Float, ?height:Float):ScriptedFlxObject
Initializes a scripted class instance using the given scripted class name and constructor arguments.
staticlistScriptClasses():Array<String>
Returns a list of all the scripted classes which extend this class.
staticscriptStaticCall(clsName:String, funcName:String):Dynamic
Call a custom static function on a scripted class, by the given name, with the given arguments.
staticscriptStaticGet(clsName:String, fieldName:String):Dynamic
Retrieves a custom static variable on a scripted class, by the given name.
staticscriptStaticSet(clsName:String, fieldName:String, ?fieldValue:Dynamic):Dynamic
Sets the value of a custom static variable on a scripted class, by the given name.
Constructor
Methods
destroy():Void
Polymod HScriptedClass override of destroy.
WARNING: A destroyed FlxBasic can't be used anymore.
It may even cause crashes if it is still part of a group or state.
You may want to use kill() instead if you want to disable the object temporarily only and revive() it later.
This function is usually not called manually (Flixel calls it automatically during state switches for all add()ed objects).
Override this function to null out variables manually or call destroy() on class members if necessary.
Don't forget to call super.destroy()!
draw():Void
Polymod HScriptedClass override of draw.
Rarely called, and in this case just increments the visible objects count and calls drawDebug() if necessary.
getCameras():Array<FlxCamera>
Polymod HScriptedClass override of getCameras.
The cameras that will draw this. Use this.cameras to set specific cameras for this object,
otherwise the container's cameras are used, or the container's container and so on. If there
is no container, say, if this is inside FlxGroups rather than a FlxContainer then the
default draw cameras are returned.
5.7.0
.getDefaultCamera():FlxCamera
Polymod HScriptedClass override of getDefaultCamera.
The main camera that will draw this. Use this.cameras to set specific cameras for this
object, otherwise the container's camera is used, or the container's container and so on.
If there is no container, say, if this is inside FlxGroups rather than a FlxContainer
then FlxG.camera is returned.
5.7.0
.getMidpoint(?point:FlxPoint):FlxPoint
Polymod HScriptedClass override of getMidpoint.
Retrieve the midpoint of this object in world coordinates.
Parameters:
point | Allows you to pass in an existing |
|---|
Returns:
A FlxPoint object containing the midpoint of this object in world coordinates.
getPosition(?result:FlxPoint):FlxPoint
Polymod HScriptedClass override of getPosition.
Returns the world position of this object.
Parameters:
result | Optional arg for the returning point. |
|---|
Returns:
The world position of this object.
getRotatedBounds(?newRect:FlxRect):FlxRect
Polymod HScriptedClass override of getRotatedBounds.
Calculates the smallest globally aligned bounding box that encompasses this
object's width and height, at its current rotation.
Note, if called on a FlxSprite, the origin is used, but scale and offset are ignored.
Use getScreenBounds to use these properties.
Parameters:
newRect | The optional output |
|---|
Returns:
A globally aligned FlxRect that fully contains the input object's width and height.
4.11.0
.getScreenPosition(?result:FlxPoint, ?camera:FlxCamera):FlxPoint
Polymod HScriptedClass override of getScreenPosition.
Returns the screen position of this object.
Parameters:
result | Optional arg for the returning point |
|---|---|
camera | The desired "screen" coordinate space. If |
Returns:
The screen position of this object.
hurt(damage:Float):Void
Polymod HScriptedClass override of hurt.
Reduces the health variable of this object by the amount specified in Damage.
Calls kill() if health drops to or below zero.
Parameters:
Damage | How much health to take away (use a negative number to give a health bonus). |
|---|
isOnScreen(?camera:FlxCamera):Bool
Polymod HScriptedClass override of isOnScreen.
Check and see if this object is currently on screen.
Parameters:
camera | Specify which game camera you want. If |
|---|
Returns:
Whether the object is on screen or not.
isPixelPerfectRender(?camera:FlxCamera):Bool
Polymod HScriptedClass override of isPixelPerfectRender.
Check if object is rendered pixel perfect on a specific camera.
kill():Void
Polymod HScriptedClass override of kill.
Handy function for "killing" game objects. Use reset() to revive them.
Default behavior is to flag them as nonexistent AND dead.
However, if you want the "corpse" to remain in the game, like to animate an effect or whatever,
you should override this, setting only alive to false, and leaving exists true.
overlaps(objectOrGroup:FlxBasic, inScreenSpace:Bool = false, ?camera:FlxCamera):Bool
Polymod HScriptedClass override of overlaps.
Checks to see if some FlxObject overlaps this FlxObject or FlxGroup.
If the group has a LOT of things in it, it might be faster to use FlxG.overlap().
WARNING: Currently tilemaps do NOT support screen space overlap checks!
Parameters:
objectOrGroup | The object or group being tested. |
|---|---|
inScreenSpace | Whether to take scroll factors into account when checking for overlap.
Default is |
camera | The desired "screen" space. If |
Returns:
Whether or not the two objects overlap.
overlapsAt(x:Float, y:Float, objectOrGroup:FlxBasic, inScreenSpace:Bool = false, ?camera:FlxCamera):Bool
Polymod HScriptedClass override of overlapsAt.
Checks to see if this FlxObject were located at the given position,
would it overlap the FlxObject or FlxGroup?
This is distinct from overlapsPoint(), which just checks that point,
rather than taking the object's size into account.
WARNING: Currently tilemaps do NOT support screen space overlap checks!
Parameters:
x | The X position you want to check. Pretends this object (the caller, not the parameter) is located here. |
|---|---|
y | The Y position you want to check. Pretends this object (the caller, not the parameter) is located here. |
objectOrGroup | The object or group being tested. |
inScreenSpace | Whether to take scroll factors into account when checking for overlap.
Default is |
camera | The desired "screen" space. If |
Returns:
Whether or not the two objects overlap.
overlapsPoint(point:FlxPoint, inScreenSpace:Bool = false, ?camera:FlxCamera):Bool
Polymod HScriptedClass override of overlapsPoint.
Checks to see if a point in 2D world space overlaps this FlxObject.
Parameters:
point | The point in world space you want to check. |
|---|---|
inScreenSpace | Whether to take scroll factors into account when checking for overlap. |
camera | The desired "screen" space. If |
Returns:
Whether or not the point overlaps this object.
reset(x:Float, y:Float):Void
Polymod HScriptedClass override of reset.
Handy function for reviving game objects. Resets their existence flags and position.
Parameters:
x | The new X position of this object. |
|---|---|
y | The new Y position of this object. |
revive():Void
Polymod HScriptedClass override of revive.
Handy function for bringing game objects "back to life". Just sets alive and exists back to true.
In practice, this function is most often called by FlxObject#reset().
scriptCall(funcName:String, ?funcArgs:Array<Dynamic>):Dynamic
Calls a function of the scripted class with the given name and arguments.
scriptSet(varName:String, ?varValue:Dynamic):Dynamic
Directly modifies the value of a local variable of a scripted class.
setPosition(x:Float = 0.0, y:Float = 0.0):Void
Polymod HScriptedClass override of setPosition.
Helper function to set the coordinates of this object. Handy since it only requires one line of code.
Parameters:
x | The new x position |
|---|---|
y | The new y position |
setSize(width:Float, height:Float):Void
Polymod HScriptedClass override of setSize.
Shortcut for setting both width and Height.
Parameters:
width | The new hitbox width. |
|---|---|
height | The new hitbox height. |
update(elapsed:Float):Void
Polymod HScriptedClass override of update.
Override this function to update your class's position and appearance. This is where most of your game rules and behavioral code will go.