1 2 3 4 5 6 | if (container == null && Greenfoot.isKeyDown( "p" )) { move(getImage().getWidth()/ 2 ); container = (Container7) getOneObjectAtOffset( 0 , 0 , Container7. class ); move(-getImage().getWidth()/ 2 ); } |


1 2 3 4 5 6 | if (container == null && Greenfoot.isKeyDown( "p" )) { move(getImage().getWidth()/ 2 ); container = (Container7) getOneObjectAtOffset( 0 , 0 , Container7. class ); move(-getImage().getWidth()/ 2 ); } |
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 | import greenfoot.*; public class Container7 extends Container1 { Ship1 ship; public Container7() { } public Container7 (Ship1 s) { ship = s; } public void act() { int x = ship.getX()- 18 ; int y = ship.getY()- 38 ; setLocation(x, y); } } |
1 2 3 4 5 6 7 8 9 10 | public void act() { if (ship != null ) { int x = ship.getX()- 18 ; int y = ship.getY()- 38 ; setLocation(x, y); } |
1 2 3 4 5 | if (container != null && Greenfoot.isKeyDown( "d" )) { container = null ; } |
1 2 3 4 5 6 7 8 9 10 | public void act() { if (ship != null ) { int x = ship.getX()- 18 ; int y = ship.getY()- 38 ; setLocation(x, y); } |
1 2 3 4 5 | if (container != null && Greenfoot.isKeyDown( "d" )) { container = null ; } |
1 2 3 4 5 6 7 8 9 | public void act() { if (schip != null ) { int x = schip.getX()- 18 ; int y = schip.getY()- 38 ; setLocation(x, y); } |