Skip to content

Instantly share code, notes, and snippets.

@KinoAR
Created April 11, 2021 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KinoAR/8e28752ed4f2ff5a7262ea4db27a3a2f to your computer and use it in GitHub Desktop.
Save KinoAR/8e28752ed4f2ff5a7262ea4db27a3a2f to your computer and use it in GitHub Desktop.
How To Setup Pathing For a FlxSprite
import flixel.util.FlxPath;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.util.FlxColor;
class Player extends FlxSprite {
public var walkPath:Array<FlxPoint>;
public function new(x:Float, y:Float) {
super(x, y);
makeGraphic(16, 16, FlxColor.WHITE, true);
walkPath = [new FlxPoint(0, 0), new FlxPoint(100, 100)];
//Creates a new FlxPath for the player to follow
this.path = new FlxPath(walkPath);
//Starts the player moving along the path and back again without stopping.
this.path.start(null, 50, FlxPath.LOOP_FORWARD);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment