I want an actor to push another actor in front of him in his current direction when he moves.
Is that possible?
if(mushroomFront()) { Actor actor = (Actor) getOneIntersectingObject(Mushroom.class); if(actor != null) { actor.setRotation(this.getRotation()); actor.move(1); } }
boolean mushroomFront() { int r = getRotation() / 90; return getOneObjectAtOffset((1-r)%2,(2-r)%2,Mushroom.class) != null; }
private Mushroom mushroomFront() { int r = getRotation()/90; return getOneObjectAtOffset((1-r)%2, (2-r)%2, Mushroom.class); }
Actor actor = mushroomFront(); if (actor != null) // etc.