I have to submit this project and I'm having an error with this code and I can't figure out what's causing it. Help would be very appreciated, thanks in advance!
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 | public void act() { controlTheArrow(); removeTheArrow(); move( 4 ); Actor actor = getOneIntersectingObject(Target. class ); if (actor != null ) { ShootingGameWorld gameWorld = (ShootingGameWorld)getWorld(); gameWorld.removeObject(actor); gameWorld.removeObject( this ); } } public void controlTheArrow() { if (Greenfoot.isKeyDown ( "right" )) { turn( 1 ); } if (Greenfoot.isKeyDown ( "left" )) { turn(- 1 ); } } public void removeTheArrow() { int xCoord = getX(); int yCoord = getY(); if (yCoord<= 0 ) { World gameWorld = getWorld(); gameWorld.removeObject( this ); } if (xCoord>= 1499 ) { World gameWorld = getWorld(); gameWorld.removeObject( this ); } } } |