I wanted to know how to reverse the direction an Actor is moving. I've tried to do it, but I can't show my code here because all my code for this is in two different classes...


class Example { public static void main(String[] args) { System.out.println("First class"); } }
class Example2 { public static void main(String[] args) { System.out.println("Second class"); } }
class Example3 { public static void main(String[] args) { System.out.println("Third class"); } }
private void ignite(boolean boosterOn) { if (boosterOn) { setImage (rocketWithThrust); addToVelocity (new Vector(getRotation(), 0.3)); } else { setImage(rocket); } }
public void checkKeys() { ignite(Greenfoot.isKeyDown("w")); Space space = (Space) getWorld(); if (Greenfoot.isKeyDown("a")) { turn(-5); } if (Greenfoot.isKeyDown("d")) { turn(5); } if (Greenfoot.isKeyDown("space")) { fire(); } }
public void move() { exactX = exactX + velocity.getX(); exactY = exactY + velocity.getY(); if (exactX >= getWorld().getWidth()) { exactX = 0; } if (exactX < 0) { exactX = getWorld().getWidth() - 1; } if (exactY >= getWorld().getHeight()) { exactY = 0; } if (exactY < 0) { exactY = getWorld().getHeight() - 1; } super.setLocation((int) exactX, (int) exactY); }
public void checkShield() { Actor shield = getOneIntersectingObject(Shield.class); if (shield != null) { getWorld().removeObject(shield); setRotation(180); } }