Hi guys,
i'm trying to accomplish the following:
Hero get hit with missile
Hero turn + 5
Hero turn - 10
Hero return back to normal position
Any ideas on how this would be implemented?
// in the Hero class, to turn 5 degrees turn(5); // in the Hero class, to turn 10 degrees to the left turn(-10);
public void checkHeroCollision(){ Actor collided = getOneIntersectingObject(Hero.class); if (collided != null){ getWorld().addObject(new explosionSmall(), getX(), getY()); getWorld().removeObject(this); collided.turn(-10); return; } else { if (getX() <= - outOfBoundary) { getWorld().removeObject(this); } } }
public void applyDamage(Missile missile) { // something like life -= missile.getDamage(); }
public int getDamage() { // return something }
public void checkHeroCollision() { Hero collided = (Hero) getOneIntersectingObject(Hero.class); if (collided != null){ collided.applyDamage(this); // the rest
cannot find symbol - method shake (Missiles)
public void shake(){ if (getRotation(this) >= -25){ setRotation(0); } }
public void shake() { if (getRotation()>= -25) { setRotation(0); } }
private int turnDelay = 0;
turnDelay++;
public void shake() { // 20 can be changed later on, I don't know what will work if (getRotation()>= -25 && turnDelay >= 20) { setRotation(0); } }
turn(-25);
turn(-1);