im trying to draw a rectangle in my game to show the player when the tactical nuke is ready, but its not showing plz help


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 | public class NukeBar extends Actor { int acts = 0 ; int NukeBarWidth = 15 ; int NukeBarHeight = 0 ; public NukeBar() { update(); } public void act() { acts = acts + 1 ; update(); if (acts == 150 ) { NukeBarHeight = NukeBarHeight + 20 ; acts = 0 ; } if (NukeBarHeight == 100 ) { if (Greenfoot.isKeyDown( "c" )) { background Background = (background)getWorld(); getWorld().removeObjects(getWorld().getObjects(enemy1. class )); } if (Greenfoot.isKeyDown( "c" )) { background Background = (background)getWorld(); getWorld().removeObjects(getWorld().getObjects(enemy2. class )); } if (Greenfoot.isKeyDown( "c" )) { background Background = (background)getWorld(); getWorld().removeObjects(getWorld().getObjects(enemy3. class )); } if (Greenfoot.isKeyDown( "c" )) { background Background = (background)getWorld(); getWorld().removeObjects(getWorld().getObjects(enemy4. class )); } } if (NukeBarHeight == 120 ) { NukeBarHeight = NukeBarHeight - 20 ; } } public void update() { setImage( new GreenfootImage(NukeBarWidth + 2 , NukeBarHeight + 2 )); GreenfootImage myImage = getImage(); myImage.setColor(Color.WHITE); myImage.drawRect( 0 , 0 ,NukeBarWidth, NukeBarHeight); myImage.setColor(Color.RED); } } |
1 2 3 4 5 6 7 | { GreenfootImage myImage = new GreenfootImage(NukeBarWidth + 2 , NukeBarHeight + 2 )); myImage.setColor(Color.WHITE); myImage.drawRect( 0 , 0 ,NukeBarWidth, NukeBarHeight); myImage.setColor(Color.RED); setImage(myImage); } |
1 2 3 4 5 6 7 | if (NukeBarHeight == 100 && Greenfoot.isKeyDown( "c" )) { getWorld().removeObjects(getWorld().getObjects(enemy1. class )); getWorld().removeObjects(getWorld().getObjects(enemy2. class )); getWorld().removeObjects(getWorld().getObjects(enemy3. class )); getWorld().removeObjects(getWorld().getObjects(enemy4. class )); } |