Okay, I don't really understand what you mean by that, but I managed to create a totally new bar and a new game over screen. There are still some errors though.
Here is my background:
It says
"illegal art of expression" and highlights "private void showGameOverCharWins()"
What should I do to fix this?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.Color; /** * Write a description of class bg1 here. * * @author (your name) * @version (a version number or a date) */ public class bg1 extends World { /** * Constructor for objects of class bg1. * */ public Bar bar = new Bar( "Pikachu" , "Health Points" , 100 , 100 ); public Bar2 bar2 = new Bar2( "Charmander" , "Health Points" , 100 , 100 ); public bg1() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super ( 600 , 400 , 1 ); addObject(bar, 250 , 40 ); addObject(bar, 400 , 40 ); prepare(); } /** * Prepare the world for the start of the program. That is: create the initial * objects and add them to the world. */ private void prepare() { Ground ground = new Ground(); addObject(ground, 293 , 393 ); Platform platform = new Platform(); addObject(platform, 291 , 193 ); Platform platform2 = new Platform(); addObject(platform2, 107 , 290 ); Platform platform3 = new Platform(); addObject(platform3, 495 , 283 ); Pikachu pikachu = new Pikachu(); addObject(pikachu, 303 , 105 ); Pikachu pikachu2 = new Pikachu(); addObject(pikachu2, 295 , 123 ); pikachu2.setLocation( 179 , 143 ); removeObject(pikachu2); pikachu.setLocation( 88 , 210 ); Charmander charmander = new Charmander(); addObject(charmander, 517 , 198 ); } GreenfootSound music = new GreenfootSound( "19 Hyrule Field Main Theme.mp3" ); public void started() { music.playLoop(); } public void act() { if (bar.getValue() == 0 ) { showGameOverCharWins(); Greenfoot.stop(); return ; } if (bar.getValue() == 0 ) { showGameoverPikaWins(); Greenfoot.stop(); return ; } private void showGameOverCharWins() { addObject( new GameOverCharWins(), getWidth() / 2 , getHeight() / 2 ); } private void showGameOverPikaWins() { addObject( new GameOverPikaWins(), getWidth() / 2 , getHeight () / 2 ); } public void stopped() { music.stop(); } } } |