Package snap.viewx

Class GameView

All Implemented Interfaces:
PropChange.DoChange, XMLArchiver.Archivable, ViewHost

public class GameView extends ChildView
This class is the main view for games and manages GameActors.
  • Constructor Details

    • GameView

      public GameView()
      Constructor.
  • Method Details

    • getCellsWide

      public int getCellsWide()
      Returns the number of cells available on X axis.
    • getCellsHigh

      public int getCellsHigh()
      Returns the number of cells available on Y axis.
    • getCellWidth

      public double getCellWidth()
      Returns the cell width.
    • getCellHeight

      public double getCellHeight()
      Returns the cell height.
    • addActorAtXY

      public void addActorAtXY(GameActor anActor, double anX, double aY)
      Adds a new actor to game view at given XY point.
    • getActor

      public GameActor getActor(String aName)
      Returns the actor with given name.
    • getActorAt

      public <T extends GameActor> T getActorAt(double aX, double aY, Class<T> aClass)
      Returns the child actor intersecting given point in local coords.
    • getActorsAt

      public <T extends GameActor> List<T> getActorsAt(double aX, double aY, Class<T> aClass)
      Returns the child actor intersecting given point in local coords.
    • removeActor

      public GameActor removeActor(int anIndex)
      Removes an actor.
    • removeActor

      public int removeActor(GameActor anActor)
      Removes an actor.
    • getFrameRate

      public double getFrameRate()
      Returns the frame rate.
    • setFrameRate

      public void setFrameRate(double aValue)
      Sets the frame rate.
    • getFrameDelay

      public int getFrameDelay()
      Returns the frame delay in milliseconds.
    • getShowCoords

      public boolean getShowCoords()
      Returns whether to draw coordinate grid.
    • setShowCoords

      public void setShowCoords(boolean aValue)
      Sets whether to draw coordinate grid.
    • setColor

      public void setColor(String aString)
      Sets the color by text.
    • getX

      public double getX(String aName)
      Returns the x value of given named actor (or "Mouse").
    • getY

      public double getY(String aName)
      Returns the y value of given named actor (or "Mouse").
    • isMouseDown

      public boolean isMouseDown()
      Returns whether the mouse button is down.
      Overrides:
      isMouseDown in class View
    • isMouseClicked

      public boolean isMouseClicked()
      Returns whether the mouse was clicked on this frame.
    • getMouseX

      public double getMouseX()
      Returns the mouse X.
    • getMouseY

      public double getMouseY()
      Returns the mouse Y.
    • getMouseButton

      public int getMouseButton()
      Returns the mouse button.
    • getMouseClickCount

      public int getMouseClickCount()
      Returns the mouse click count.
    • isKeyDown

      public boolean isKeyDown(String aKey)
      Returns whether a given key is pressed.
    • isKeyClicked

      public boolean isKeyClicked(String aKey)
      Returns whether a given key was pressed in the current frame.
    • start

      public void start()
      Starts the animation.
    • stop

      public void stop()
      Stops the animation.
    • isPlaying

      public boolean isPlaying()
      Returns whether game is playing.
    • isAutoStart

      public boolean isAutoStart()
      Returns whether game autostarts.
    • setAutoStart

      public void setAutoStart(boolean aValue)
      Sets whether game autostarts.
    • setShowing

      protected void setShowing(boolean aValue)
      Override to start/stop animation.
      Overrides:
      setShowing in class ParentView
    • processEvent

      protected void processEvent(ViewEvent anEvent)
      Process event.
      Overrides:
      processEvent in class View
    • act

      protected void act()
      The act method.
    • paintFront

      protected void paintFront(Painter aPntr)
      Paints the canvas.
      Overrides:
      paintFront in class View