Package snap.games

Class Actor

All Implemented Interfaces:
PropChange.DoChange, XMLArchiver.Archivable
Direct Known Subclasses:
BoardActor, PenActor

public class Actor extends ParentView
This class represents a game character in a GameView.
  • Field Details

  • Constructor Details

    • Actor

      public Actor()
      Constructor.
  • Method Details

    • getGameView

      public GameView getGameView()
      Returns the GameView.
    • getGameView

      public <T extends GameView> T getGameView(Class<? extends GameView> aClass)
      Returns the GameView as given class.
    • getImage

      public Image getImage()
      Returns the image.
    • setImage

      public void setImage(Image anImage)
      Sets the image.
    • setImageForName

      public void setImageForName(String imageName)
      Sets the image for given name.
    • moveBy

      public void moveBy(double aCount)
      Move actor forward.
    • moveToXY

      public void moveToXY(double anX, double aY)
      Move actor to a point using setRotation and moveBy (so pen drawing works).
    • turnBy

      public void turnBy(double theDegrees)
      Turn actor by given degrees.
    • turnToXY

      public void turnToXY(double aX, double aY)
      Turn actor to given point X/Y.
    • turnToActor

      public void turnToActor(Actor anActor)
      Turn actor to given point X/Y.
    • scaleBy

      public void scaleBy(double aScale)
      Scale actor by given amount.
    • isIntersectingActor

      public boolean isIntersectingActor(Class<?> aClass)
      Returns the actors intersecting this actor that match given class (class can be null).
    • getIntersectingActor

      public <T> T getIntersectingActor(Class<T> aClass)
      Returns the actors intersecting this actor that match given class (class can be null).
    • getIntersectingActors

      public <T> List<T> getIntersectingActors(Class<T> aClass)
      Returns the actors intersecting this actor that match given class (class can be null).
    • isIntersectingActor

      protected boolean isIntersectingActor(Actor anActor, Class<?> aClass)
      Returns whether given actor is intersecting and of matching class (class can be null).
    • getActorInRange

      public <T> T getActorInRange(double aRadius, Class<T> aClass)
      Returns the first actor in given range radius that match given class (class can be null).
    • getActorsInRange

      public <T> List<T> getActorsInRange(double aRadius, Class<T> aClass)
      Returns the actors in given range radius that match given class (class can be null).
    • isActorInRange

      protected boolean isActorInRange(Actor anActor, double aRadius, Class<?> aClass)
      Returns whether given actor is in range and of matching class (class can be null).
    • getActorAtXY

      public <T> T getActorAtXY(double aX, double aY, Class<T> aClass)
      Returns the first actor hit by given point that match given class (class can be null).
    • getActorsAtXY

      public <T> List<T> getActorsAtXY(double aX, double aY, Class<T> aClass)
      Returns the actors hit by given point that match given class (class can be null).
    • getAngleToXY

      public double getAngleToXY(double aX, double aY)
      Returns the angle of the line from this actor center point to given point.
    • getAngleToActor

      public double getAngleToActor(Actor anActor)
      Returns the angle of the line from this actor center point to given point.
    • getAngleToMouse

      public double getAngleToMouse()
      Returns the angle of the line from this actor center point to current mouse point.
    • getDistanceToXY

      public double getDistanceToXY(double aX, double aY)
      Returns the distance from this actor center point to given point.
    • getDistanceToActor

      public double getDistanceToActor(Actor anActor)
      Returns the distance from this actor center point to given actor center point.
    • intersectsActor

      public boolean intersectsActor(Actor anActor)
      Returns whether actor intersects given actor.
    • isAtGameViewEdge

      public boolean isAtGameViewEdge()
      Returns whether at edge.
    • act

      protected void act()
      The act method.
    • layoutImpl

      protected void layoutImpl()
      Layout.
      Overrides:
      layoutImpl in class ParentView
    • getPrefWidthImpl

      protected double getPrefWidthImpl(double aH)
      Pref width.
      Overrides:
      getPrefWidthImpl in class View
    • getPrefHeightImpl

      protected double getPrefHeightImpl(double aW)
      Pref height.
      Overrides:
      getPrefHeightImpl in class View