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?


1 2 3 4 | // in the Hero class, to turn 5 degrees turn( 5 ); // in the Hero class, to turn 10 degrees to the left turn(- 10 ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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 ); } } } |
1 2 3 4 | public void applyDamage(Missile missile) { // something like life -= missile.getDamage(); } |
1 2 3 4 | public int getDamage() { // return something } |
1 2 3 4 5 | public void checkHeroCollision() { Hero collided = (Hero) getOneIntersectingObject(Hero. class ); if (collided != null ){ collided.applyDamage( this ); // the rest |
1 | cannot find symbol - method shake (Missiles) |
1 2 3 4 5 | public void shake(){ if (getRotation( this ) >= - 25 ){ setRotation( 0 ); } } |
1 2 3 4 5 6 | public void shake() { if (getRotation()>= - 25 ) { setRotation( 0 ); } } |
1 | private int turnDelay = 0 ; |
1 | turnDelay++; |
1 2 3 4 5 6 7 | public void shake() { // 20 can be changed later on, I don't know what will work if (getRotation()>= - 25 && turnDelay >= 20 ) { setRotation( 0 ); } } |
1 | turn(- 25 ); |
1 | turn(- 1 ); |