Update Food class

// step 1: add bBox attribute private Area bBox; // step 2: instantiate bBox in setShapeAttributes() method bBox = new Area(foodShape); // step 3: add a new method private Shape getBoundary() public Shape getBoundary() { AffineTransform at = new AffineTransform(); at.translate(pos.x, pos.y); at.scale(scale, scale); return at.createTransformedShape(bBox); } // step 4: update public boolean checkMouseHit(MouseEvent e) public boolean checkMouseHit(MouseEvent e) { return getBoundary().contains(e.getX(), e.getY()); }
Code to update Food class
IAT 265 (Fall 2017)
Lab 05

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.