
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | public class Head extends Shooter { public boolean isGrabbed; /** * Act - do whatever the Head wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { grab(); setRotation(((Actor) getWorld().getObjects(Slider. class ).get( 0 )).getRotation()); if (Greenfoot.mouseClicked( this )) { Bullet peluru = new Bullet(); getWorld().addObject(peluru,getX(),getY()); peluru.setRotation(((Actor) getWorld().getObjects(Head. class ).get( 0 )).getRotation()); peluru.setImage( "bullet3.png" ); } // Add your action code here. } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | public class Bullet extends Actor { /** * Act - do whatever the Bullet wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { move( 2 ); if ( this .isAtEdge()) getWorld().removeObject( this ); //System.out.println(getRotation()); // Add your action code here. } } |