jetlag2d
    Preparing search index...

    Class PathMovement

    A rule for moving along a fixed path

    Index
    • Create a policy for moving an actor along a fixed path

      Parameters

      • cfg: {
            loop: boolean;
            path: Path;
            startPoint?: number;
            velocity: number;
            waypointCallback?: (which: number) => void;
        }
        • loop: boolean

          Should the path repeat infinitely, or just run once?

        • path: Path

          The path on which to move

        • OptionalstartPoint?: number

          The point on the path from which to start

        • velocity: number

          The speed at which the actor should move

        • OptionalwaypointCallback?: (which: number) => void

          Code to run each time a waypoint of the path is reached, including the final one. It is given the index of that waypoint. On a looping path, the final waypoint is followed immediately by waypoint 0.

      Returns PathMovement

    • Stop the actor where it is, and hold it there until resume() is called. It's safe to call this from the waypointCallback, so that an actor can stop when it reaches a waypoint.

      Returns void

    • Carry on toward the next waypoint, from wherever the actor is now. Does nothing if the movement isn't paused. The waypointCallback is not run again for the waypoint that the actor stopped at.

      Returns void