Created
April 11, 2021 17:21
-
-
Save KinoAR/8e28752ed4f2ff5a7262ea4db27a3a2f to your computer and use it in GitHub Desktop.
How To Setup Pathing For a FlxSprite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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