Enum Class Direction

java.lang.Object
java.lang.Enum<Direction>
games.stendhal.common.Direction
All Implemented Interfaces:
Serializable, Comparable<Direction>, Constable

public enum Direction extends Enum<Direction>
a direction to face or walk to
Author:
hendrik
  • Enum Constant Details

    • STOP

      public static final Direction STOP
      do not move
    • UP

      public static final Direction UP
      up, away from the screen
    • DOWN

      public static final Direction DOWN
      down, facing the player
    • LEFT

      public static final Direction LEFT
      to the left
  • Method Details

    • values

      public static Direction[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Direction valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • build

      public static Direction build(int val)
      converts an integer to a Direction
      Parameters:
      val - int
      Returns:
      Direction
    • getdx

      public int getdx()
      gets the delta on the x-axis
      Returns:
      delta x
    • getdy

      public int getdy()
      gets the delta on the y-axis
      Returns:
      dy
    • rand

      public static Direction rand()
      gets a random direction
      Returns:
      Direction
    • get

      public int get()
      gets the index
      Returns:
      index
    • getAreaDirectionTowardsArea

      public static Direction getAreaDirectionTowardsArea(Rectangle2D area1, Rectangle2D area2)
      Compares two area and return the direction of area2 towards area1. So if area2 is left of area1, it will return Direction.LEFT
      Parameters:
      area1 - The area to compare with
      area2 - The area to be compared
      Returns:
      The Direction of area2 as seen from area1
    • oppositeDirection

      public abstract Direction oppositeDirection()
      gets the opposite direction
      Returns:
      Direction
    • nextDirection

      public abstract Direction nextDirection()
      gets the next direction clockwise
      Returns:
      Direction