i want an actor to face another one, so that he can move towards him just with the method
move(1);
i dont know how to adjust this...
I hope you can help me


1 2 3 4 5 6 7 | public void act() { Ship ship= (Ship) getWorld().getObjects(Ship. class ).get( 0 ); turnTowards(ship.getX(), ship.getY()); setRotation(getRotation() - 90 ); move( 2 ); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | public DartLaser() { try { Ship ship = (Ship) getWorld().getObjects(Ship. class ).get( 0 ); turnTowards(ship.getX(), ship.getY()); } catch (IndexOutOfBoundsException ex) {} } public void act() { X = getX(); Y = getY(); move( 4 ); if (getY() >= 649 ) { getWorld().removeObject( this ); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | public DartLaser() { } public void addedToWorld(World world) { if (!world.getObjects(Ship. class ).isEmpty()) { Ship ship = (Ship)world.getObjects(Ship. class ).get( 0 ); turnTowards(ship.getX(), ship.getY()); } } public void act() { X = getX(); Y = getY(); move( 4 ); if (getY() >= 649 ) { getWorld().removeObject( this ); } |