Codename Logo Codename Logo

Custom Classes

APIWiki

Custom Classes

Custom classes can be made either inside the script you need it in or you can make a script file corresponding with the name of the class in ./source, and using import to import it.

Here is a basic Song Script code that uses it:

class SpecialSprite extends FlxSprite {
    public var customValue:String = null;
    public function new(?x:Float = 0, ?y:Float = 0, ?graphic:FlxGraphicAsset, customValue:String) { // it also has to start with the same arguments as the super class, (limitation for now)
        super(x, y, graphic); // this does nothing currently, its purely visual for now, but it will be used in the future
        this.customValue = customValue;
        //other code stuff
    }

    public override function update(elapsed) {
        super.update(elapsed);
    }
}

function create() {
    var spr = new SpecialSprite(200, 400, null, "powerful");
    add(spr);
}

Particularities

As of writing this, this system is very limited and also presents some defects. For example:

Written by: Ne_Eo & Frakits
Last updated: 2024-09-11