phaser - v4.0.0-rc.4
    Preparing search index...

    Function ShiftPosition

    • Takes an array of items, such as Game Objects, or any objects with public x and y properties and then iterates through them. As this function iterates, it moves the position of the current element to be that of the previous entry in the array. This repeats until all items have been moved.

      The direction controls the order of iteration. A value of 0 (the default) assumes that the final item in the array is the 'head' item.

      A direction value of 1 assumes that the first item in the array is the 'head' item.

      The position of the 'head' item is set to the x/y values given to this function. Every other item in the array is then updated, in sequence, to be that of the previous (or next) entry in the array.

      The final x/y coords are returned, or set in the 'output' Vector2.

      Think of it as being like the game Snake, where the 'head' is moved and then each body piece is moved into the space of the previous piece.

      Type Parameters

      Parameters

      • items: G

        An array of Game Objects, or objects with public x and y positions. The contents of this array are updated by this Action.

      • x: number

        The x coordinate to place the head item at.

      • y: number

        The y coordinate to place the head item at.

      • Optionaldirection: number

        The iteration direction. 0 = first to last and 1 = last to first. Default 0.

      • Optionaloutput: O

        An optional Vec2Like object to store the final position in.

      Returns O