Class View
- java.lang.Object
-
- View
-
- All Implemented Interfaces:
EventListener,javafx.event.EventHandler<javafx.scene.input.KeyEvent>
public class View extends Object implements javafx.event.EventHandler<javafx.scene.input.KeyEvent>
-
-
Field Summary
Fields Modifier and Type Field Description GameObjballThe batGameObjbatGameObj[]bricksThe balljavafx.scene.canvas.Canvascanvasbasic layout paneControllercontrollerThe other parts of the model-view-controller setupintheightwidth of windowjavafx.scene.control.LabelinfoTextcanvas to draw game onModelmodeljavafx.scene.layout.Panepaneuser interface objectsintscoreThe bricksintwidthvariables for components of the user interface
-
Constructor Summary
Constructors Constructor Description View(int w, int h)constructor method - we get told the width and height of the window
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddisplayGameObj(javafx.scene.canvas.GraphicsContext gc, GameObj go)Display a game object - it is just a rectangle on the canvasvoiddrawPicture()drawing the game imagevoidhandle(javafx.scene.input.KeyEvent event)Event handler for key presses - it just passes the event to the controllervoidstart(javafx.stage.Stage window)start is called from the Main class, to start the GUI upvoidupdate()This is how the Model talks to the View This method gets called BY THE MODEL, whenever the model changes It has to do whatever is required to update the GUI to show the new game position
-
-
-
Field Detail
-
width
public int width
variables for components of the user interface
-
height
public int height
width of window
-
pane
public javafx.scene.layout.Pane pane
user interface objects
-
canvas
public javafx.scene.canvas.Canvas canvas
basic layout pane
-
infoText
public javafx.scene.control.Label infoText
canvas to draw game on
-
controller
public Controller controller
The other parts of the model-view-controller setup
-
model
public Model model
-
bat
public GameObj bat
-
ball
public GameObj ball
The bat
-
bricks
public GameObj[] bricks
The ball
-
score
public int score
The bricks
-
-
Method Detail
-
start
public void start(javafx.stage.Stage window)
start is called from the Main class, to start the GUI up
-
handle
public void handle(javafx.scene.input.KeyEvent event)
Event handler for key presses - it just passes the event to the controller- Specified by:
handlein interfacejavafx.event.EventHandler<javafx.scene.input.KeyEvent>
-
drawPicture
public void drawPicture()
drawing the game image
-
displayGameObj
public void displayGameObj(javafx.scene.canvas.GraphicsContext gc, GameObj go)Display a game object - it is just a rectangle on the canvas
-
update
public void update()
This is how the Model talks to the View This method gets called BY THE MODEL, whenever the model changes It has to do whatever is required to update the GUI to show the new game position
-
-